-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
38 lines (33 loc) · 905 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import test from 'ava';
import s3Filename from '.';
test('should throw error on invalid params', t => {
t.throws(() => {
s3Filename(123);
}, Error);
t.throws(() => {
s3Filename(null);
}, Error);
t.throws(() => {
s3Filename();
}, Error);
t.throws(() => {
s3Filename({});
}, Error);
t.throws(() => {
s3Filename('abc', {separator: '?'});
}, Error);
});
test('should pass on valid params', t => {
t.notThrows(() => {
s3Filename('abc-s32', {separator: '-'});
});
});
test('should remove special characters from string except !()-_*.', t => {
t.is(s3Filename('123#@%$^&@456!-)+=*_'), '123456!-)*_');
});
test('should remove latin characters from string to their english counter parts', t => {
t.is(s3Filename('áêīòü'), 'aeiou');
});
test('should make the filename sane', t => {
t.is(s3Filename('some 漢字 ćööł % #fíłéñàmé.jpg'), 'some-cool-filename.jpg');
});