Guest User

Untitled

a guest
Jun 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import {} from 'jasmine';
  2. import {trimSuffix, trimPrefix} from './string';
  3. describe('string utils', () => {
  4. describe('trimSuffix', () => {
  5. for (const [from, trim, to] of [
  6. [null, 'abc', null],
  7. ['abc', 'c', 'ab'],
  8. ['abc', '', 'abc'],
  9. ['abc', null, 'abc'],
  10. ['abc', 'bc', 'a'],
  11. ['abc', 'abc', ''],
  12. ['abc', 'abcd', 'abc'],
  13. ['abc', 'aabc', 'abc'],
  14. ['abcdabc', 'abc', 'abcd'],
  15. ['abcabc', 'abc', 'abc'],
  16. ['abcdabc', 'd', 'abcdabc'],
  17. ]) {
  18. it(`(from=${from}, trim=${trim}) => to=${to}`, () => {
  19. expect(trimSuffix(from,trim)).toEqual(to);
  20. });
  21. }
  22. });
  23. describe('trimPrefix', () => {
  24. for (const [from, trim, to] of [
  25. [null, 'abc', null],
  26. ['abc', 'a', 'bc'],
  27. ['abc', 'ab', 'c'],
  28. ['abc', '', 'abc'],
  29. ['abc', null, 'abc'],
  30. ['abc', 'd', 'abc'],
  31. ['abc', 'abc', ''],
  32. ['abc', 'abcd', 'abc'],
  33. ['abcdabc', 'abc', 'dabc'],
  34. ['abcabc', 'abc', 'abc'],
  35. ['abcdabc', 'd', 'abcdabc'],
  36. ]) {
  37. it(`(from=${from}, trim=${trim}) => to=${to}`, () => {
  38. expect(trimPrefix(from,trim)).toEqual(to);
  39. });
  40. }
  41. });
  42. });
Add Comment
Please, Sign In to add comment