Skip to content

Commit

Permalink
Test for #81
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonkristan committed Oct 10, 2015
1 parent b7b6a16 commit 104fcc5
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion test/attribute_type/array.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
(function() {
'use strict';

var store;
var type = EG.ArrayType.create();

module('Array Attribute Type Test');
module('Array Attribute Type Test', {
setup: function() {
store = setupStore({
lotteryTicket: EG.Model.extend({
numbers: EG.attr('array')
})
});

store.pushPayload({
lotteryTicket: [
{
id: '1',
numbers: [4, 8, 15, 16, 23, 42]
}
]
});
}
});

test('Comparison works correctly', function() {
expect(5);
Expand All @@ -14,4 +32,15 @@
ok(!type.isEqual([1, 2], [2, 1]));
ok(!type.isEqual([''], [null]));
});

test('Changes can be observed', 2, function() {
var ticket = store.getRecord('lotteryTicket', '1');

ticket.addObserver('numbers.[]', function() {
ok(true);
});

ticket.get('numbers').pushObject(0);
ticket.set('numbers', ticket.get('numbers').slice(0, 6));
});
})();

0 comments on commit 104fcc5

Please sign in to comment.