File: es.string.raw.js

package info (click to toggle)
node-core-js 3.33.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,828 kB
  • sloc: javascript: 87,204; makefile: 13
file content (21 lines) | stat: -rw-r--r-- 861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
QUnit.test('String.raw', assert => {
  const { raw } = String;
  assert.isFunction(raw);
  assert.arity(raw, 1);
  assert.name(raw, 'raw');
  assert.looksNative(raw);
  assert.nonEnumerable(String, 'raw');
  assert.same(raw({ raw: ['Hi\\n', '!'] }, 'Bob'), 'Hi\\nBob!', 'raw is array');
  assert.same(raw({ raw: 'test' }, 0, 1, 2), 't0e1s2t', 'raw is string');
  assert.same(raw({ raw: 'test' }, 0), 't0est', 'lacks substituting');
  assert.same(raw({ raw: [] }), '', 'empty template');

  if (typeof Symbol == 'function' && !Symbol.sham) {
    const symbol = Symbol('raw test');
    assert.throws(() => raw({ raw: [symbol] }, 0), TypeError, 'throws on symbol #1');
    assert.throws(() => raw({ raw: 'test' }, symbol), TypeError, 'throws on symbol #2');
  }

  assert.throws(() => raw({}), TypeError);
  assert.throws(() => raw({ raw: null }), TypeError);
});