Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("when returning no result", async function(assert) {
mockQueryRecord('user');
FactoryGuy.store.queryRecord('user', {});
assert.ok(true);
});
test("when returning no result", async function(assert) {
mockQueryRecord('user');
FactoryGuy.store.queryRecord('user', {});
assert.ok(true);
});
run(async () => {
let bob = make('user');
mockQueryRecord('user', {name: 'Bob'}).returns({id: bob.id});
let user = await FactoryGuy.store.queryRecord('user', {name: 'Bob'});
assert.equal(user, bob, "returns the same user");
assert.equal(FactoryGuy.store.peekAll('user').get('content').length, 1, "does not create a new model");
});
});
return run(async () => {
let company1 = build('company'),
company2 = build('company');
mockQueryRecord('company', {name: 'Dude'}).returns({json: company1});
mockQueryRecord('company', {type: 'Small'}).returns({json: company2});
let company = await FactoryGuy.store.queryRecord('company', {name: 'Dude'});
assert.equal(company.get('id'), company1.get('id'));
company = await FactoryGuy.store.queryRecord('company', {type: 'Small'});
assert.equal(company.get('id'), company2.get('id'));
});
});
run(async () => {
let bob = make('user');
mockQueryRecord('user', {name: 'Bob'}).returns({id: bob.id});
let user = await FactoryGuy.store.queryRecord('user', {name: 'Bob'});
assert.equal(user, bob, "returns the same user");
assert.equal(FactoryGuy.store.peekAll('user').get('content').length, 1, "does not create a new model");
});
});
return run(async () => {
let company1 = build('company'),
company2 = build('company');
let mockQuery = mockQueryRecord('company', {name: 'Dude'}).returns({json: company1});
let company = await FactoryGuy.store.queryRecord('company', {name: 'Dude'});
assert.equal(company.get('id'), company1.get('id'));
mockQuery.withParams({type: 'Small'}).returns({json: company2});
company = await FactoryGuy.store.queryRecord('company', {type: 'Small'});
assert.equal(company.get('id'), company2.get('id'));
});
});