Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {} from 'jasmine';
- import {trimSuffix, trimPrefix} from './string';
- describe('string utils', () => {
- describe('trimSuffix', () => {
- for (const [from, trim, to] of [
- [null, 'abc', null],
- ['abc', 'c', 'ab'],
- ['abc', '', 'abc'],
- ['abc', null, 'abc'],
- ['abc', 'bc', 'a'],
- ['abc', 'abc', ''],
- ['abc', 'abcd', 'abc'],
- ['abc', 'aabc', 'abc'],
- ['abcdabc', 'abc', 'abcd'],
- ['abcabc', 'abc', 'abc'],
- ['abcdabc', 'd', 'abcdabc'],
- ]) {
- it(`(from=${from}, trim=${trim}) => to=${to}`, () => {
- expect(trimSuffix(from,trim)).toEqual(to);
- });
- }
- });
- describe('trimPrefix', () => {
- for (const [from, trim, to] of [
- [null, 'abc', null],
- ['abc', 'a', 'bc'],
- ['abc', 'ab', 'c'],
- ['abc', '', 'abc'],
- ['abc', null, 'abc'],
- ['abc', 'd', 'abc'],
- ['abc', 'abc', ''],
- ['abc', 'abcd', 'abc'],
- ['abcdabc', 'abc', 'dabc'],
- ['abcabc', 'abc', 'abc'],
- ['abcdabc', 'd', 'abcdabc'],
- ]) {
- it(`(from=${from}, trim=${trim}) => to=${to}`, () => {
- expect(trimPrefix(from,trim)).toEqual(to);
- });
- }
- });
- });
Add Comment
Please, Sign In to add comment