consul/ui-v2/tests/unit/utils/right-trim-test.js

46 lines
1.1 KiB
JavaScript

import { module } from 'qunit';
import test from 'ember-sinon-qunit/test-support/test';
import rightTrim from 'consul-ui/utils/right-trim';
module('Unit | Utility | right trim', function() {
test('it trims characters from the right hand side', function(assert) {
[
{
args: ['/a/folder/here/', '/'],
expected: '/a/folder/here',
},
{
args: ['/a/folder/here', ''],
expected: '/a/folder/here',
},
{
args: ['a/folder/here', '/'],
expected: 'a/folder/here',
},
{
args: ['a/folder/here/', '/'],
expected: 'a/folder/here',
},
{
args: [],
expected: '',
},
{
args: ['/a/folder/here', '/folder/here'],
expected: '/a',
},
{
args: ['/a/folder/here', 'a/folder/here'],
expected: '/',
},
{
args: ['/a/folder/here/', '/a/folder/here/'],
expected: '',
},
].forEach(function(item) {
const actual = rightTrim(...item.args);
assert.equal(actual, item.expected);
});
});
});