test/unit/angularjs/rails/extensions/snapshotsSpec.js in angularjs-rails-resource-1.1.1 vs test/unit/angularjs/rails/extensions/snapshotsSpec.js in angularjs-rails-resource-1.2.0

- old
+ new

@@ -346,9 +346,34 @@ expect(book.$key).toBe('1234'); expect(firstCallbackCalled).toBe(true); expect(secondCallbackCalled).toBe(true); }); + it('should detect unsnapped changes', function () { + var book, data = {id: 1, $key: '1234', name: 'The Winds of Winter', theAuthor: 'George R.R. Martin'}; + book = new Book(data); + expect(book.unsnappedChanges()).toBe(true); + + book.snapshot(); + expect(book.unsnappedChanges()).toBe(false); + + book.name = 'Harry Potter'; + expect(book.unsnappedChanges()).toBe(true); + + book.snapshot(); + expect(book.unsnappedChanges()).toBe(false); + + book.theAuthor = 'J.K. Rowling'; + expect(book.unsnappedChanges()).toBe(true); + + book.snapshot(); + expect(book.unsnappedChanges()).toBe(false); + + // angular.equals ignores $-prefixed properties + book.$key = '1235' + expect(book.unsnappedChanges()).toBe(false); + }); + describe('serializer', function () { beforeEach(function () { Book.configure({ serializer: railsSerializer(function () { this.exclude('author'); \ No newline at end of file