Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE]: Modernize record-persistence-test #7630

Merged
merged 2 commits into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (

test("When a store is committed, the adapter's `updateRecord` method should be called with records that have been changed.", async function (assert) {
assert.expect(2);

const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand Down Expand Up @@ -56,16 +56,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (
test("When a store is committed, the adapter's `createRecord` method should be called with records that have been created.", async function (assert) {
assert.expect(2);

const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand All @@ -91,16 +92,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (
test('After a created record has been assigned an ID, finding a record by that ID returns the original record.', async function (assert) {
assert.expect(1);

const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand All @@ -112,7 +114,7 @@ module('integration/adapter/record_persistence - Persisting Records', function (
let tom;

adapter.createRecord = function (store, type, snapshot) {
return resolve({ data: { id: 1, type: 'person', attributes: { name: 'Tom Dale' } } });
return resolve({ data: { id: '1', type: 'person', attributes: { name: 'Tom Dale' } } });
};

tom = store.createRecord('person', { name: 'Tom Dale' });
Expand All @@ -124,16 +126,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (
});

test("when a store is committed, the adapter's `deleteRecord` method should be called with records that have been deleted.", async function (assert) {
const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand Down Expand Up @@ -169,16 +172,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (
});

test('An adapter can notify the store that a record was updated and provide new data by calling `didSaveRecord`.', async function (assert) {
const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand Down Expand Up @@ -265,16 +269,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (
});

test('An adapter can notify the store that records were deleted by calling `didSaveRecords`.', async function (assert) {
const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand Down Expand Up @@ -322,16 +327,17 @@ module('integration/adapter/record_persistence - Persisting Records', function (
test('Create record response does not have to include the type property', async function (assert) {
assert.expect(2);

const Person = Model.extend({
updatedAt: attr('string'),
name: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
});

const ApplicationAdapter = Adapter.extend({
shouldBackgroundReloadRecord: () => false,
});
class Person extends Model {
@attr('string') updatedAt;
@attr('string') name;
@attr('string') firstName;
@attr('string') lastName;
}
class ApplicationAdapter extends Adapter {
shouldBackgroundReloadRecord() {
return false;
}
}

this.owner.register('model:person', Person);
this.owner.register('adapter:application', ApplicationAdapter);
Expand Down