/ test / packages / left-pad / test.js
test.js
 1  import * as assert from 'assert';
 2  import * as fc from 'fast-check';
 3  const leftPad = require('left-pad');
 4  
 5  const lengthUnicode = s => [...s].length;
 6  
 7  describe('left-pad', () => {
 8    it('should be able to pad simple strings with utf-16 characters', () => {
 9      fc.assert(
10        fc.property(
11          fc.unicodeString(),
12          fc.nat(100),
13          fc.fullUnicode(),
14          (s, additionalPad, c) =>
15            lengthUnicode(leftPad(s, lengthUnicode(s) + additionalPad, c)) === lengthUnicode(s) + additionalPad
16        )
17      );
18    });
19    xit('should be able to pad utf-16 strings', () => {
20      fc.assert(
21        fc.property(
22          fc.fullUnicodeString(),
23          fc.nat(100),
24          (s, additionalPad) =>
25            lengthUnicode(leftPad(s, lengthUnicode(s) + additionalPad)) === lengthUnicode(s) + additionalPad
26        )
27      );
28    });
29  });