2020-09-08 16:53:51 +00:00
|
|
|
import { isWildcardString } from 'vault/helpers/is-wildcard-string';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
|
|
|
module('Unit | Helpers | is-wildcard-string', function() {
|
|
|
|
test('it returns true if regular string with wildcard', function(assert) {
|
|
|
|
let string = 'foom#*eep';
|
2020-09-15 18:11:24 +00:00
|
|
|
let result = isWildcardString(string);
|
2020-09-08 16:53:51 +00:00
|
|
|
assert.equal(result, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it returns false if no wildcard', function(assert) {
|
|
|
|
let string = 'foo.bar';
|
2020-09-15 18:11:24 +00:00
|
|
|
let result = isWildcardString(string);
|
2020-09-08 16:53:51 +00:00
|
|
|
assert.equal(result, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it returns true if string with id as in searchSelect selected has wildcard', function(assert) {
|
|
|
|
let string = { id: 'foo.bar*baz' };
|
2020-09-15 18:11:24 +00:00
|
|
|
let result = isWildcardString(string);
|
2020-09-08 16:53:51 +00:00
|
|
|
assert.equal(result, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it returns true if string object has name and no id', function(assert) {
|
|
|
|
let string = { name: 'foo.bar*baz' };
|
2020-09-15 18:11:24 +00:00
|
|
|
let result = isWildcardString(string);
|
2020-09-08 16:53:51 +00:00
|
|
|
assert.equal(result, true);
|
|
|
|
});
|
|
|
|
|
2020-09-08 20:24:27 +00:00
|
|
|
test('it returns true if string object has name and id with at least one wildcard', function(assert) {
|
2020-09-08 16:53:51 +00:00
|
|
|
let string = { id: '7*', name: 'seven' };
|
2020-09-15 18:11:24 +00:00
|
|
|
let result = isWildcardString(string);
|
2020-09-08 16:53:51 +00:00
|
|
|
assert.equal(result, true);
|
|
|
|
});
|
2020-09-08 20:24:27 +00:00
|
|
|
|
|
|
|
test('it returns true if string object has name and id with wildcard in name not id', function(assert) {
|
|
|
|
let string = { id: '7', name: 'sev*n' };
|
2020-09-15 18:11:24 +00:00
|
|
|
let result = isWildcardString(string);
|
2020-09-08 20:24:27 +00:00
|
|
|
assert.equal(result, true);
|
|
|
|
});
|
2020-09-08 16:53:51 +00:00
|
|
|
});
|