Skip to content

Commit

Permalink
[CHORE]: Modernize queries-test (#7629)
Browse files Browse the repository at this point in the history
* modernized to class-based model definitions

* stringify ids

* .equal()->strictEqual()
  • Loading branch information
runnerboy22 authored Apr 15, 2022
1 parent e0326e7 commit e86c12e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/-ember-data/tests/integration/adapter/queries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module('integration/adapter/queries - Queries', function (hooks) {
});

testInDebug('It raises an assertion when no type is passed', function (assert) {
const Person = Model.extend();
class Person extends Model {}

this.owner.register('model:person', Person);

Expand All @@ -31,7 +31,7 @@ module('integration/adapter/queries - Queries', function (hooks) {
});

testInDebug('It raises an assertion when no query hash is passed', function (assert) {
const Person = Model.extend();
class Person extends Model {}

this.owner.register('model:person', Person);

Expand All @@ -43,7 +43,9 @@ module('integration/adapter/queries - Queries', function (hooks) {
});

test('When a query is made, the adapter should receive a record array it can populate with the results of the query.', async function (assert) {
const Person = Model.extend({ name: attr() });
class Person extends Model {
@attr name;
}

this.owner.register('model:person', Person);

Expand Down Expand Up @@ -73,7 +75,7 @@ module('integration/adapter/queries - Queries', function (hooks) {
});
};

let queryResults = await store.query('person', { page: 1 });
let queryResults = await store.query('person', { page: '1' });

assert.strictEqual(queryResults.length, 2, 'the record array has a length of 2 after the results are loaded');
assert.true(queryResults.isLoaded, "the record array's `isLoaded` property should be true");
Expand All @@ -85,7 +87,7 @@ module('integration/adapter/queries - Queries', function (hooks) {
test('a query can be updated via `update()`', async function (assert) {
assert.expect(8);

const Person = Model.extend();
class Person extends Model {}

this.owner.register('model:person', Person);

Expand Down Expand Up @@ -132,7 +134,9 @@ module('integration/adapter/queries - Queries', function (hooks) {
testInDebug(
'The store asserts when query is made and the adapter responses with a single record.',
async function (assert) {
const Person = Model.extend({ name: attr() });
class Person extends Model {
@attr name;
}

this.owner.register('model:person', Person);

Expand All @@ -143,12 +147,12 @@ module('integration/adapter/queries - Queries', function (hooks) {
assert.strictEqual(type, Person, 'the query method is called with the correct type');

return resolve({
data: { id: 1, type: 'person', attributes: { name: 'Peter Wagenet' } },
data: { id: '1', type: 'person', attributes: { name: 'Peter Wagenet' } },
});
};

await assert.expectAssertion(async () => {
await store.query('person', { page: 1 });
await store.query('person', { page: '1' });
}, /The response to store.query is expected to be an array but it was a single record/);
}
);
Expand Down

0 comments on commit e86c12e

Please sign in to comment.