github.com/hernad/nomad@v1.6.112/ui/tests/unit/adapters/variable-test.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import { module, test } from 'qunit'; 7 import { setupTest } from 'ember-qunit'; 8 9 module('Unit | Adapter | Variable', function (hooks) { 10 setupTest(hooks); 11 12 test('Correctly pluralizes lookups with shortened path', async function (assert) { 13 this.store = this.owner.lookup('service:store'); 14 this.subject = () => this.store.adapterFor('variable'); 15 16 let newVariable = await this.store.createRecord('variable'); 17 // we're incorrectly passing an object with a `Model` interface 18 // we should be passing a `Snapshot` 19 // hacky fix to rectify the issue 20 newVariable.attr = () => {}; 21 22 assert.equal( 23 this.subject().urlForFindAll('variable'), 24 '/v1/vars', 25 'pluralizes findAll lookup' 26 ); 27 assert.equal( 28 this.subject().urlForFindRecord('foo/bar', 'variable', newVariable), 29 `/v1/var/${encodeURIComponent('foo/bar')}?namespace=default`, 30 'singularizes findRecord lookup' 31 ); 32 }); 33 });