Created
November 11, 2011 08:50
-
-
Save caligo-mentis/1357531 to your computer and use it in GitHub Desktop.
toJSON spec
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
| describe('toJSON', function() { | |
| var Address = SC.Resource.define({ | |
| schema: { | |
| city: String, | |
| } | |
| }); | |
| var Person = SC.Resource.define({ | |
| schema: { | |
| id: Number, | |
| name: String, | |
| address: { | |
| type: Address, | |
| nested: true | |
| } | |
| } | |
| }); | |
| var attributes = { | |
| name: 'John Smit', | |
| address: { | |
| city: 'London', | |
| } | |
| }; | |
| it('should return updated values of nested objects', function() { | |
| var person = Person.create(attributes), | |
| newCity = 'Liverpool', | |
| newName = 'Smit Johnson'; | |
| SC.setPath(person, 'address.city', newCity); | |
| SC.set(person, 'name', newName); | |
| // Ok | |
| expect(SC.get(person, 'name')).toBe(newName); | |
| expect(person.toJSON().name).toBe(newName); | |
| // Fail | |
| expect(SC.getPath(person, 'address.city')).toBe(newCity); | |
| expect(person.toJSON().address.city).toBe(newCity); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment