Last active
August 29, 2015 14:05
-
-
Save RyanHirsch/9bb5f7832ca5ffd7baa6 to your computer and use it in GitHub Desktop.
EmberData Model Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { test, moduleForModel } from 'ember-qunit'; | |
| moduleForModel('user-profile', 'UserProfile', { | |
| // Specify the other units that are required for this test. | |
| needs: [] | |
| }); | |
| test('display name works', function() { | |
| var model = this.subject(); | |
| var store = this.store(); | |
| var managerFoo = this.subject({ | |
| first: "First", | |
| last: "Last" | |
| }); | |
| equal(managerFoo.get('displayName'), 'First Last'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import DS from 'ember-data'; | |
| var attr = DS.attr; | |
| var hasMany = DS.hasMany; | |
| var belongsTo = DS.belongsTo; | |
| export default DS.Model.extend({ | |
| prefix: attr('string'), | |
| first: attr('string'), | |
| middle: attr('string'), | |
| last: attr('string'), | |
| suffix: attr('string'), | |
| title: attr('string'), | |
| priPhone: attr('string'), | |
| altPhone: attr('string'), | |
| site: attr('string'), | |
| email: attr('string'), | |
| firstLogon: attr('date'), | |
| displayName: function() { | |
| return '%@ %@'.fmt(this.get('first'), this.get('last')); | |
| }.property('first', 'last') | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment