open-nomad/ui/tests/integration/helpers/trim-path-test.js
2023-04-10 15:36:59 +00:00

35 lines
1.2 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Helper | trim-path', function (hooks) {
setupRenderingTest(hooks);
test('it doesnt mess with internal slashes', async function (assert) {
this.set('inputValue', 'a/b/c/d');
await render(hbs`{{trim-path this.inputValue}}`);
assert.dom(this.element).hasText('a/b/c/d');
});
test('it will remove a prefix slash', async function (assert) {
this.set('inputValue', '/a/b/c/d');
await render(hbs`{{trim-path this.inputValue}}`);
assert.dom(this.element).hasText('a/b/c/d');
});
test('it will remove a suffix slash', async function (assert) {
this.set('inputValue', 'a/b/c/d/');
await render(hbs`{{trim-path this.inputValue}}`);
assert.dom(this.element).hasText('a/b/c/d');
});
test('it will remove both at once', async function (assert) {
this.set('inputValue', '/a/b/c/d/');
await render(hbs`{{trim-path this.inputValue}}`);
assert.dom(this.element).hasText('a/b/c/d');
});
});