mirror of
https://github.com/hanzoai/core-js.git
synced 2026-09-24 16:58:15 +00:00
22 lines
870 B
JavaScript
22 lines
870 B
JavaScript
QUnit.test('String.cooked', assert => {
|
|
const { cooked } = String;
|
|
assert.isFunction(cooked);
|
|
assert.arity(cooked, 1);
|
|
assert.name(cooked, 'cooked');
|
|
assert.looksNative(cooked);
|
|
assert.nonEnumerable(String, 'cooked');
|
|
assert.same(cooked(['Hi\\n', '!'], 'Bob'), 'Hi\\nBob!', 'template is an array');
|
|
assert.same(cooked('test', 0, 1, 2), 't0e1s2t', 'template is a string');
|
|
assert.same(cooked('test', 0), 't0est', 'lacks substituting');
|
|
assert.same(cooked([]), '', 'empty template');
|
|
|
|
if (typeof Symbol == 'function' && !Symbol.sham) {
|
|
const symbol = Symbol('cooked test');
|
|
assert.throws(() => cooked([symbol]), TypeError, 'throws on symbol #1');
|
|
assert.throws(() => cooked('test', symbol), TypeError, 'throws on symbol #2');
|
|
}
|
|
|
|
assert.throws(() => cooked([undefined]), TypeError);
|
|
assert.throws(() => cooked(null), TypeError);
|
|
});
|