Skip to content

Commit 93c0b3b

Browse files
committed
Add a few basic util tests
1 parent f5a4418 commit 93c0b3b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/tests/utils.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { wrapAround, containsOnlyLettersAndUnderscores, replaceIllegalFileNameCharactersInString} from '../utils/Utils';
2+
3+
test('If wrapAround wraps correctly', () => {
4+
expect(wrapAround(100,5)).toBe(0);
5+
expect(wrapAround(100,7)).toBe(2);
6+
});
7+
8+
test('If wrapAround errors out when dividing by zero', () => {
9+
expect(wrapAround(100,0)).toThrow();
10+
});
11+
12+
test('Letter and underscore string validity', () => {
13+
expect(containsOnlyLettersAndUnderscores("asdkfj_")).toBe(true);
14+
expect(containsOnlyLettersAndUnderscores("asdkfj0")).toBe(false);
15+
});
16+
17+
test('Letter and underscore unicode char test', () =>{
18+
expect(containsOnlyLettersAndUnderscores("asdkaÈj")).toBe(true);
19+
expect(containsOnlyLettersAndUnderscores("asdkaÈj0")).toBe(false);
20+
});
21+
22+
test('Valid filename test', ()=>{
23+
expect(replaceIllegalFileNameCharactersInString("what?is\\this:")).toBe("whatisthis -");
24+
})

0 commit comments

Comments
 (0)