adopted-ember-addons / adopted-ember-addons/ember-data-model-fragments
Integration test: Uncaught TypeError: store.createFragment is not a function
- Langage dominant
- TypeScript
- Étoiles
- 367
- Forks
- 108
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I am trying to write an integration test for a component that manipulates a model called `spot`.
Here is the spot model:
```
// models/spot.js
// imports...
// some validations rules...
const Validations = buildValidations({ ... });
export default Model.extend( Validations, {
customMeta : fragmentArray('custom-meta'),
name: attr("string"),
location: fragment('location', {
defaultValue: {
lat: null,
lon: null
}
}),
```
I am trying to create a spot record in such an integration test:
```
test('should render card displaying name, content, status correctly', function(assert) {
let spotMock;
const store = this.container.lookup('service:store');
run(()=>{
spotMock = store.createRecord('spot', {
isMoving: true,
name: 'spot-name',
// no matter whether the following is present or absent, the error persists
// location: store.createFragment('location', {
// lat: 1,
// lon: 1
// })
});
});
//...
```
`store.createRecord()` fails due to:
_Uncaught TypeError: store.createFragment is not a function_
This is the place which calls `store.createFragment()`:
```
// fragment.js
// Creates a fragment and sets its owner to the given record
function createFragment(store, declaredModelName, record, key, options, data) {
var actualModelName = getActualFragmentType(declaredModelName, options, data);
var fragment = store.createFragment(actualModelName); // error
setFragmentOwner(fragment, record, key);
setFragmentData(fragment, data);
return fragment;
}
```
Maybe a screenshot helps:

Apparently, `createFragment()` is not set up upon the store yet. Do I have to set it up anyhow for the purposes of integration testing? I could not find any hint about it in the docs, however, I guess I am missing something simple in here.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.