Skip to content

Commit

Permalink
Merge pull request #1124 from embroider-build/ember-data-test-coverage
Browse files Browse the repository at this point in the history
improving ember-data test coverage
  • Loading branch information
ef4 authored Feb 10, 2022
2 parents 59959c8 + ad08f5f commit 26bb2a7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/compat/src/addon-dependency-rules/ember-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ let rules: PackageRules[] = [
'-private/system/core-store.js': {
dependsOnModules: ['@ember-data/record-data/-private'],
},
'-private/system/model/internal-model.js': {
dependsOnModules: ['@ember-data/model/-private'],
},
},
},
];
Expand Down
48 changes: 48 additions & 0 deletions tests/scenarios/static-app-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ appScenarios

merge(project.files, {
app: {
adapters: {
'post.js': `
import JSONAPIAdapter from '@ember-data/adapter/json-api';
export default class PostAdapter extends JSONAPIAdapter {
findRecord(store, type, id, snapshot) {
return { data: { type: 'posts', id: '0 ', attributes: { title: 'Hello world' } } };
}
}
`,
},
components: {
'fancy-box.js': `
import Component from '@glimmer/component';
Expand Down Expand Up @@ -58,6 +68,27 @@ appScenarios
export default helper(loadedHelpers);
`,
},
models: {
'post.js': `
import Model, { attr } from '@ember-data/model';
export default class PostModel extends Model {
@attr() title;
}
`,
},
routes: {
'ember-data-example.js': `
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class EmberDataExampleRoute extends Route {
@service() store;
model() {
return this.store.findRecord('post', 0);
}
}
`,
},
templates: {
components: {
'default-title.hbs': `
Expand Down Expand Up @@ -98,6 +129,7 @@ appScenarios
<FancyBox @title="With Default" />
<FancyBox @title="With Custom" @titleComponent="my-title" />
`,
'ember-data-example.hbs': `<h1>{{@model.title}}</h1>`,
},
'router.js': `
import EmberRouter from '@ember/routing/router';
Expand All @@ -113,6 +145,7 @@ appScenarios
this.route('components-example');
this.route('static-component-rules-example');
this.route('macros-example');
this.route('ember-data-example');
});
`,
},
Expand Down Expand Up @@ -212,6 +245,21 @@ appScenarios
});
});
`,
'ember-data-example-test.js': `
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
module('Acceptance | ember data example', function (hooks) {
setupApplicationTest(hooks);
test('visiting /ember-data-example', async function (assert) {
await visit('/ember-data-example');
assert.equal(currentURL(), '/ember-data-example');
assert.dom('h1').containsText('Hello world');
});
});
`,
},
unit: {
'missing-import-sync-renamed-test.js': `
Expand Down

0 comments on commit 26bb2a7

Please sign in to comment.