vault/ui/tests/unit/utils/trim-right-test.js
Matthew Irish 85d7ffea83
UI - upgrading generic secret engines to v2 format (#4750)
* remove dev-leased-kv flag, handle non-secret responses in the console

* skip lease tests for now

* use the newer collection api for ember-page-object

* include generic in types that can have a v2

* add tests for generic v2

* isolate kv v2 logic in the secret-engine model and add unit tests
2018-06-13 23:06:19 -05:00

29 lines
1019 B
JavaScript

import trimRight from 'vault/utils/trim-right';
import { module, test } from 'qunit';
module('Unit | Util | trim right');
test('it trims extension array from end of string', function(assert) {
const trimmedName = trimRight('my-file-name-is-cool.json', ['.json', '.txt', '.hcl', '.policy']);
assert.equal(trimmedName, 'my-file-name-is-cool');
});
test('it only trims extension array from the very end of string', function(assert) {
const trimmedName = trimRight('my-file-name.json-is-cool.json', ['.json', '.txt', '.hcl', '.policy']);
assert.equal(trimmedName, 'my-file-name.json-is-cool');
});
test('it returns string as is if trim array is empty', function(assert) {
const trimmedName = trimRight('my-file-name-is-cool.json', []);
assert.equal(trimmedName, 'my-file-name-is-cool.json');
});
test('it returns string as is if trim array is not passed in', function(assert) {
const trimmedName = trimRight('my-file-name-is-cool.json');
assert.equal(trimmedName, 'my-file-name-is-cool.json');
});