-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,25 @@ module('Store.createRecord() coverage', function (hooks) { | |
store = owner.lookup('service:store'); | ||
}); | ||
|
||
test("createRecord doesn't crash when setter is involved", async function (assert) { | ||
class User extends Model { | ||
@attr() email; | ||
|
||
get name() { | ||
return this.email ? this.email.substring(0, this.email.indexOf('@')) : ''; | ||
} | ||
|
||
set name(value) { | ||
this.email = `${value.toLowerCase()}@ember.js`; | ||
} | ||
} | ||
this.owner.register(`model:user`, User); | ||
const store = this.owner.lookup('service:store'); | ||
|
||
const user = store.createRecord('user', { name: 'Robert' }); | ||
assert.strictEqual(user.email, '[email protected]'); | ||
}); | ||
|
||
test('unloading a newly created a record with a sync belongsTo relationship', async function (assert) { | ||
let chris = store.push({ | ||
data: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { set } from '@ember/object'; | ||
import { run } from '@ember/runloop'; | ||
import { settled } from '@ember/test-helpers'; | ||
import Ember from 'ember'; | ||
|
@@ -11,7 +10,6 @@ import { setupTest } from 'ember-qunit'; | |
|
||
import RESTAdapter from '@ember-data/adapter/rest'; | ||
import { REQUEST_SERVICE } from '@ember-data/canary-features'; | ||
import Model, { attr } from '@ember-data/model'; | ||
import JSONAPISerializer from '@ember-data/serializer/json-api'; | ||
import RESTSerializer from '@ember-data/serializer/rest'; | ||
import deepCopy from '@ember-data/unpublished-test-infra/test-support/deep-copy'; | ||
|
@@ -1344,26 +1342,3 @@ module('integration/store - queryRecord', function (hooks) { | |
} | ||
}); | ||
}); | ||
|
||
module('integration/store - createRecord', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test("createRecord doesn't crash when setter is involved", async function (assert) { | ||
class User extends Model { | ||
@attr() email; | ||
|
||
get name() { | ||
return this.email ? this.email.substring(0, this.email.indexOf('@')) : ''; | ||
} | ||
|
||
set name(value) { | ||
set(this, 'email', `${value.toLowerCase()}@ember.js`); | ||
} | ||
} | ||
this.owner.register(`model:user`, User); | ||
const store = this.owner.lookup('service:store'); | ||
|
||
const user = store.createRecord('user', { name: 'Robert' }); | ||
assert.strictEqual(user.email, '[email protected]'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters