StringUtils.spec.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { assert } from 'chai';
  2. import { StringUtils } from '../../../src/utils/StringUtils';
  3. describe('StringUtils', function () {
  4. this.timeout(30000);
  5. describe('escapeJsString', () => {
  6. describe('Variant #1: single quotes', () => {
  7. const expectedEscapedJsString: string = 'const foo = \\\'Hello World!\\\'';
  8. let escapedJsString: string;
  9. before(() => {
  10. escapedJsString = StringUtils.escapeJsString('const foo = \'Hello World!\'');
  11. });
  12. it('should escape js string', () => {
  13. assert.equal(escapedJsString, expectedEscapedJsString);
  14. });
  15. });
  16. describe('Variant #2: double quotes', () => {
  17. const expectedEscapedJsString: string = 'const foo = \\"Hello World!\\"';
  18. let escapedJsString: string;
  19. before(() => {
  20. escapedJsString = StringUtils.escapeJsString('const foo = "Hello World!"');
  21. });
  22. it('should escape js string', () => {
  23. assert.equal(escapedJsString, expectedEscapedJsString);
  24. });
  25. });
  26. });
  27. });