test: 💍 add tests for adapter and serializer scope options

This commit is contained in:
Randall Morey committed 2020-09-03 14:48:59 -04:00
1 parent bce27df1f4
commit 2eeb73b622
6 files changed
+76 -8

No files matched your search

@@ -35,14 +35,16 @@ module('Unit | Adapter | application', function (hooks) {
assert.equal(prefix, `v1/scopes/${scopeID}`);
});
test('it does not prefixes URLs with `scopeID` for scope resources', function (assert) {
assert.expect(1);
test('it does not prefix URLs with `scopeID` when hasScopePrefix is `false`', function (assert) {
assert.expect(2);
const scopeID = 'global';
const adapter = this.owner.lookup('adapter:application');
const prefix = adapter.urlPrefix(null, null, 'scope', null, {
adapter.hasScopePrefix = false;
const prefix = adapter.urlPrefix(null, null, null, null, {
adapterOptions: { scopeID }
});
assert.equal(prefix, `v1`);
assert.ok(config.api.namespace);
assert.equal(prefix, 'v1');
});
test('it generates correct default URL suffixes', function (assert) {
@@ -6,6 +6,16 @@ module('Unit | Adapter | scope', function(hooks) {
setupTest(hooks);
setupMirage(hooks);
test('it does not prefix URLs with `scopeID` for scope resources', function (assert) {
assert.expect(1);
const scopeID = 'global';
const adapter = this.owner.lookup('adapter:scope');
const prefix = adapter.urlPrefix(null, null, 'scope', null, {
adapterOptions: { scopeID }
});
assert.equal(prefix, `v1`);
});
test('it generates correct createRecord URLs with a scope_id query parameter', function (assert) {
assert.expect(1);
this.server.post('/v1/scopes', (schema, { queryParams }) =>{