Skip to content

Instantly share code, notes, and snippets.

@caligo-mentis
Created November 11, 2011 08:50
Show Gist options
  • Select an option

  • Save caligo-mentis/1357531 to your computer and use it in GitHub Desktop.

Select an option

Save caligo-mentis/1357531 to your computer and use it in GitHub Desktop.
toJSON spec
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