Files
threshold-ui/addons/api/tests/unit/mixins/adapter-build-url-test.js
T
Zhihe Li 999c21c66a Upgrade eslint (#3175)
* chore: 🤖 Upgrade eslint config for admin ui

* chore: 🤖 Fix eslint issues for admin

* chore: 🤖 Upgrade eslint config for desktop

* chore: 🤖 Fix linting errors in desktop

* chore: 🤖 Upgrade eslint for api addon

* chore: 🤖 Fix eslint issues in api addon

* chore: 🤖 Upgrade eslint for auth addon

* chore: 🤖 Fix eslint issues in auth addon

* chore: 🤖 Upgrade core eslint config

* chore: 🤖 Fix eslint issue for core addon

* chore: 🤖 Upgrade eslint config for rose addon

* chore: 🤖 Fix eslint issue for rose addon

* chore: 🤖 Upgrade e2e eslint config

* chore: 🤖 Fix eslint issues in e2e

* chore: 🤖 Fix CI linting issues

* chore: 🤖 Add back linting server files for the future

* chore: 🤖 Update qunit rules to use extends
2026-02-27 13:32:27 -05:00

61 lines
2.2 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import RESTAdapter from '@ember-data/adapter/rest';
/* eslint-disable-next-line ember/no-mixins */
import AdapterBuildURLMixin from 'api/mixins/adapter-build-url';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Mixin | build-url', function (hooks) {
setupTest(hooks);
test('it does not interfere with basic URLs', function (assert) {
/* eslint-disable-next-line ember/no-new-mixins */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin);
this.owner.register('adapter:adapter', Adapter);
const adapter = this.owner.lookup('adapter:adapter');
const url = adapter._buildURL('model', 1);
assert.strictEqual(url, '/models/1');
});
test('it does not interfere with namespaced URLs', function (assert) {
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin, {
namespace: 'api/v1',
});
this.owner.register('adapter:adapter', Adapter);
const adapter = this.owner.lookup('adapter:adapter');
const url = adapter._buildURL('model', 1);
assert.strictEqual(url, '/api/v1/models/1');
});
test('it can prepend a prefix', function (assert) {
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin, {
urlPrefix() {
return '/foo/bars';
},
});
this.owner.register('adapter:adapter', Adapter);
const adapter = this.owner.lookup('adapter:adapter');
const url = adapter._buildURL('model', 1);
assert.strictEqual(url, '/foo/bars/models/1');
});
test('it can append a suffix', function (assert) {
/* eslint-disable-next-line ember/no-new-mixins, ember/no-classic-classes */
const Adapter = RESTAdapter.extend(AdapterBuildURLMixin, {
urlSuffix() {
return ':method';
},
});
this.owner.register('adapter:adapter', Adapter);
const adapter = this.owner.lookup('adapter:adapter');
const url = adapter._buildURL('model', 1);
assert.strictEqual(url, '/models/1:method');
});
});