|
427 | 427 | })
|
428 | 428 | })
|
429 | 429 |
|
| 430 | + describe('- stripLeft(chars)', function () { |
| 431 | + |
| 432 | + it('should return the new string with all occurences of `chars` removed from left', function () { |
| 433 | + T (S('hello').stripLeft().s === 'hello'); |
| 434 | + T (S('hello').stripLeft('').s === 'hello'); |
| 435 | + T (S(' hello ').stripLeft().s === 'hello '); |
| 436 | + T (S('foo ').stripLeft().s === 'foo '); |
| 437 | + T (S('').stripLeft().s === ''); |
| 438 | + T (S(null).stripLeft().s === ''); |
| 439 | + T (S(undefined).stripLeft().s === ''); |
| 440 | + T (S('aazz').stripLeft('a').s === 'zz'); |
| 441 | + T (S('yytest').stripLeft('t').s === 'yytest'); |
| 442 | + T (S('xxxyyxx').stripLeft('x').s === 'yyxx'); |
| 443 | + T (S('abcz').stripLeft('a-z').s === 'bcz'); |
| 444 | + T (S('z alpha z').stripLeft('a-z').s === ' alpha z'); |
| 445 | + T (S('_-foobar-_').stripLeft('_-').s === 'foobar-_'); |
| 446 | + |
| 447 | + T (S('_.foo-_').stripLeft('_.').s === 'foo-_'); |
| 448 | + T (S('?foo ').stripLeft('?').s === 'foo '); |
| 449 | + T (S('[$]hello-^').stripLeft('^[a-z]$').s === 'hello-^'); |
| 450 | + |
| 451 | + T (S(123).stripLeft(1).s === '23'); |
| 452 | + }); |
| 453 | + }); |
| 454 | + |
| 455 | + describe('- stripRight(chars)', function () { |
| 456 | + |
| 457 | + it('should return the new string with all occurences of `chars` removed from right', function () { |
| 458 | + T (S('hello').stripRight().s === 'hello'); |
| 459 | + T (S('hello').stripRight('').s === 'hello'); |
| 460 | + T (S(' hello ').stripRight().s === ' hello'); |
| 461 | + T (S(' foo').stripRight().s === ' foo'); |
| 462 | + T (S('').stripRight().s === ''); |
| 463 | + T (S(null).stripRight().s === ''); |
| 464 | + T (S(undefined).stripRight().s === ''); |
| 465 | + T (S('aazz').stripRight('z').s === 'aa'); |
| 466 | + T (S('xxxyyxx').stripRight('x').s === 'xxxyy'); |
| 467 | + T (S('abcz').stripRight('a-z').s === 'abc'); |
| 468 | + T (S('z alpha z').stripRight('a-z').s === 'z alpha '); |
| 469 | + T (S('_-foobar-_').stripRight('_-').s === '_-foobar'); |
| 470 | + |
| 471 | + T (S('_.foo_.').stripRight('_.').s === '_.foo'); |
| 472 | + T (S(' foo?').stripRight('?').s === ' foo'); |
| 473 | + T (S('[$]hello-^').stripRight('^[a-z]$').s === '[$]hello'); |
| 474 | + |
| 475 | + T (S(123).stripRight(3).s === '12'); |
| 476 | + }); |
| 477 | + }); |
| 478 | + |
430 | 479 | describe('+ restorePrototype()', function() {
|
431 | 480 | it('should restore the original String prototype', function() {
|
432 | 481 | T (typeof ' hi'.endsWith === 'undefined');
|
|
0 commit comments