Sha256: 6093ef2d65a37108883afc6df7de2eb2e088a447b73ef7aee0840de55134b794

Contents?: true

Size: 1.29 KB

Versions: 46

Compression:

Stored size: 1.29 KB

Contents

import {
    expect
} from 'chai';
import wrapWord from './../src/wrapWord';

describe('wrapWord', () => {
  it('wraps a string at a nearest whitespace', () => {
    expect(wrapWord('aaa bbb', 5)).to.deep.equal(['aaa', 'bbb']);
    expect(wrapWord('a a a bbb', 5)).to.deep.equal(['a a a', 'bbb']);
  });
  context('a single word is longer than chunk size', () => {
    it('cuts the word', () => {
      expect(wrapWord('aaaaa', 2)).to.deep.equal(['aa', 'aa', 'a']);
    });
  });
  context('a long word with a special character', () => {
    it('cuts the word at the special character', () => {
      expect(wrapWord('aaa\\bbb', 5)).to.deep.equal(['aaa\\', 'bbb']);
      expect(wrapWord('aaa/bbb', 5)).to.deep.equal(['aaa/', 'bbb']);
      expect(wrapWord('aaa_bbb', 5)).to.deep.equal(['aaa_', 'bbb']);
      expect(wrapWord('aaa-bbb', 5)).to.deep.equal(['aaa-', 'bbb']);
      expect(wrapWord('aaa.bbb', 5)).to.deep.equal(['aaa.', 'bbb']);
      expect(wrapWord('aaa,bbb', 5)).to.deep.equal(['aaa,', 'bbb']);
      expect(wrapWord('aaa;bbb', 5)).to.deep.equal(['aaa;', 'bbb']);
    });
  });
  context('a special character after the length of a container', () => {
    it('does not include special character', () => {
      expect(wrapWord('aa-bbbbb-cccc', 5)).to.deep.equal(['aa-', 'bbbbb', '-cccc']);
    });
  });
});

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-17.6.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.5.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.4.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.3.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.2.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.1.1 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.1.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-17.0.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.29.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.28.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.27.1 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.27.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.26.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.25.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.24.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.23.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.22.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.21.0 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.20.1 node_modules/table/test/wrapWord.js
govuk_publishing_components-16.20.0 node_modules/table/test/wrapWord.js