Skip to content

Commit

Permalink
add missing test (collection items should call their .toJSON)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchase committed Aug 20, 2016
1 parent dfd6344 commit 5fae1c7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/core.mixins.collection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const chai = require('chai');
const sinon = require('sinon');
const expect = chai.expect;

const mix = require('../src/core/mixins/mix');
Expand Down Expand Up @@ -77,7 +78,20 @@ describe('Collection', function(){
expect(collection.toJSON().items).to.be.an('array');
});

it('calls toJSON() on items if they have a toJSON method');
it('calls toJSON() on items if they have a toJSON method', function() {
const collectionItem = {
type: "component",
id: 3,
toJSON: function() {}
}

sinon.spy(collectionItem, 'toJSON');

collection.pushItem(collectionItem);
collection.toJSON();
expect(collectionItem.toJSON.called).to.be.true;
collection.removeItem(collectionItem);
});
});

describe('.first()', function(){
Expand Down

0 comments on commit 5fae1c7

Please sign in to comment.