feat: Refactor to ResourceFilteringStore service
This commit is contained in:
6 files changed
+83
-106
No files matched your search
@@ -1,37 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { Response } from 'miragejs';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
|
||||
module('Unit | Service | filterable-store', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
let store;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
store = this.owner.lookup('service:filterable-store');
|
||||
|
||||
store.createRecord('session', {
|
||||
id: 'i_1234567890',
|
||||
scope: {
|
||||
id: '123',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('it supports query filtering', function (assert) {
|
||||
this.server.get('/v1/sessions?scope_id=123', () => {
|
||||
new Response({});
|
||||
});
|
||||
store.filterByIds('session', { scope_id: '123' });
|
||||
assert.ok(store);
|
||||
});
|
||||
|
||||
test('it supports single attribute filters', function (assert) {
|
||||
assert.ok(store);
|
||||
});
|
||||
|
||||
test('it supports multiple attribute filters', function (assert) {
|
||||
assert.ok(store);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Service | resource-filtering-store', function (hooks) {
|
||||
setupTest(hooks);
|
||||
let service, store;
|
||||
hooks.beforeEach(function () {
|
||||
service = this.owner.lookup('service:resource-filtering-store');
|
||||
store = this.owner.lookup('service:store');
|
||||
|
||||
store.createRecord('session', {
|
||||
id: 's_1',
|
||||
scope: {
|
||||
id: '123',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(service);
|
||||
});
|
||||
|
||||
// TODO: Is it possible to capture mirage API requests in this test?
|
||||
// test('it supports query filters', function (assert) {
|
||||
// const models = service.queryBy('session', {}, { scope_id: '123' });
|
||||
// assert.ok(service);
|
||||
// });
|
||||
});
|
||||
Reference in new issue
Block a user