open-nomad/ui/tests/integration/helpers/trim-path-test.js
Phil Renaud da4cb6422e Secure Variables: Build a path tree and traverse it at /variables/*path (#13202)
* Recursive trie-building with variable paths

* tree structure applied to new path routes and a new util class

* Breadcrumbs for SV paths and prompt when nothing exists at a path

* Lint and test cleanup

* Pre-review cleanup

* lintfix

* Abstracted pathtree each-ins into a new component class

* Path tree component styles

* Types added and PR feedback addressed

* Path tree to variable paths

* Slightly simpler path QP mods

* More pr feedback handling

* Trim moved into a function on variable model

* Traversal and compaction tests for PathTree

* Trim Path tests

* Variable-paths component tests

* Lint fixup for tests
2022-07-11 13:34:04 -04:00

30 lines
1.1 KiB
JavaScript

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');
});
});