scratch-vm/test/unit/util_string.js
Ray Schamp bafdf8d9f2 Use ES6 linting rules in the project root
Update all tests for `no-var` and `prefer-arrow-callback` (using `--fix`)
2017-04-24 15:37:58 -04:00

57 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const test = require('tap').test;
const StringUtil = require('../../src/util/string-util');
test('withoutTrailingDigits', t => {
t.strictEqual(StringUtil.withoutTrailingDigits('boeing747'), 'boeing');
t.strictEqual(StringUtil.withoutTrailingDigits('boeing747 '), 'boeing747 ');
t.strictEqual(StringUtil.withoutTrailingDigits('boeing𝟨'), 'boeing𝟨');
t.strictEqual(StringUtil.withoutTrailingDigits('boeing 747'), 'boeing ');
t.strictEqual(StringUtil.withoutTrailingDigits('747'), '');
t.end();
});
test('unusedName', t => {
t.strictEqual(
StringUtil.unusedName(
'name',
['not the same name']
),
'name'
);
t.strictEqual(
StringUtil.unusedName(
'name',
['name']
),
'name2'
);
t.strictEqual(
StringUtil.unusedName(
'name',
['name30']
),
'name'
);
t.strictEqual(
StringUtil.unusedName(
'name',
['name', 'name2']
),
'name3'
);
t.strictEqual(
StringUtil.unusedName(
'name',
['name', 'name3']
),
'name2'
);
t.strictEqual(
StringUtil.unusedName(
'boeing747',
['boeing747']
),
'boeing2' // Yup, this matches scratch-flash...
);
t.end();
});