Ember.run(function () { var done = assert.async(); TestHelper.handleFindQuery('user', ['name']); FactoryGuy.getStore().query('user', {name: 'Bob'}).then(function (users) { equal(users.get('length'), 0); done(); }); });
Ember.run(function () { var done = assert.async(); var users = FactoryGuy.makeList('user', 2, 'with_hats'); TestHelper.handleFindQuery('user', ['name'], users); equal(FactoryGuy.getStore().peekAll('user').get('content.length'), 2, 'start out with 2 instances'); FactoryGuy.getStore().query('user', {name: 'Bob'}).then(function (users) { equal(users.get('length'), 2); equal(users.get('firstObject.name'), 'User1'); equal(users.get('firstObject.hats.length'), 2); equal(users.get('lastObject.name'), 'User2'); equal(FactoryGuy.getStore().peekAll('user').get('content.length'), 2, 'no new instances created'); done(); }); });
Ember.run(function () { var done = assert.async(); var users = FactoryGuy.makeList('company', 2, 'with_projects', 'with_profile'); TestHelper.handleFindQuery('company', ['name'], users); equal(FactoryGuy.getStore().peekAll('company').get('content.length'), 2, 'start out with 2 instances'); FactoryGuy.getStore().query('company', {name: 'Dude'}).then(function (companies) { equal(companies.get('length'), 2); ok(companies.get('firstObject.profile') instanceof Profile); equal(companies.get('firstObject.projects.length'), 2); ok(companies.get('lastObject.profile') instanceof Profile); equal(companies.get('lastObject.projects.length'), 2); equal(FactoryGuy.getStore().peekAll('company').get('content.length'), 2, 'no new instances created'); done(); }); });
assert.throws(function () { TestHelper.handleFindQuery('user', ['name'], {}); }, "payload argument is not an array");
assert.throws(function () { TestHelper.handleFindQuery('user', 'name', {}); }, "second argument not correct type");