File tree Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ import { assertEquals } from "https://deno.land/std@0.203.0/assert/assert_equals.ts" ;
2+ import trimCharacters from "./trim_characters.ts" ;
3+
4+ Deno . test (
5+ 'Trim characters at the start of a string.' ,
6+ async ( test ) => {
7+ await test . step ( {
8+ name : 'Empty input string, empty characters' ,
9+ fn : ( ) => {
10+ assertEquals (
11+ trimCharacters ( '' , '' ) ,
12+ ''
13+ )
14+ }
15+ } )
16+
17+ await test . step ( {
18+ name : 'Empty characters' ,
19+ fn : ( ) => {
20+ assertEquals (
21+ trimCharacters ( 'abc123' , '' ) ,
22+ 'abc123'
23+ )
24+ }
25+ } )
26+
27+ await test . step ( {
28+ name : 'Empty input string' ,
29+ fn : ( ) => {
30+ assertEquals (
31+ trimCharacters ( '' , 'abc' ) ,
32+ ''
33+ )
34+ }
35+ } )
36+
37+ await test . step ( {
38+ name : 'Fake Escaped characters in input string' ,
39+ fn : ( ) => {
40+ assertEquals (
41+ trimCharacters ( '\aabc123\a' , '\a' ) ,
42+ 'bc123'
43+ )
44+ }
45+ } )
46+
47+ await test . step ( {
48+ name : 'Real Escaped characters in input string' ,
49+ fn : ( ) => {
50+ assertEquals (
51+ trimCharacters ( '\ttabc123t\t' , '\t' ) ,
52+ 'tabc123'
53+ )
54+ }
55+ } )
56+
57+ await test . step ( {
58+ name : 'Skip characters in input string' ,
59+ fn : ( ) => {
60+ assertEquals (
61+ trimCharacters ( '321abc123' , '1' ) ,
62+ '321abc123'
63+ )
64+ }
65+ } )
66+
67+ await test . step ( {
68+ name : 'Normal trim' ,
69+ fn : ( ) => {
70+ assertEquals (
71+ trimCharacters ( 'abc123' , 'cab23' ) ,
72+ '1'
73+ )
74+ }
75+ } )
76+ }
77+ )
You can’t perform that action at this time.
0 commit comments