feat: 🎸 tweak resource-filter service and apply to sessions

This commit is contained in:
Randall Morey committed 2021-11-09 12:42:39 -05:00
1 parent cd6f87b796
commit 751a72a2d8
7 files changed
+108 -85

No files matched your search

@@ -0,0 +1,18 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { ResourceFilter } from 'api/services/resource-filter-store';
module('Unit | Service | resource-filter-store', function (hooks) {
setupTest(hooks);
test('it exports a ResourceFilter class that converts filterObjects to query expressions', function (assert) {
assert.ok(ResourceFilter);
const filter = new ResourceFilter({
type: 'oidc',
status: ['active', 'pending'],
});
const expected =
'("/item/type" == "oidc") and ("/item/status" == "active" or "/item/status" == "pending")';
assert.equal(filter.queryExpression, expected);
});
});
@@ -1,29 +0,0 @@
import { module, test, skip } 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?
skip('it supports query filters', function (assert) {
service.queryBy('session', {}, { scope_id: '123' });
assert.ok(service);
});
});