forked from bldrs-ai/Share
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFiletype.test.js
36 lines (32 loc) · 1021 Bytes
/
Filetype.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
import {
FilenameParseError,
isExtensionSupported,
pathSuffixSupported,
splitAroundExtension,
supportedTypes,
} from './Filetype'
describe('Filetype', () => {
const unsupportedFiletypes = ['arff', 'zip']
it('supports only known extensions', () => {
for (const ext of supportedTypes) {
expect(isExtensionSupported(ext)).toBe(true)
const path = `foo/bar/baz.${ext}`
expect(pathSuffixSupported(path)).toBe(true)
}
for (const ext of unsupportedFiletypes) {
expect(isExtensionSupported(ext)).toBe(false)
const path = `foo/bar/baz.${ext}`
expect(pathSuffixSupported(path)).toBe(false)
}
})
it('splitAroundExtension', () => {
for (const ext of supportedTypes) {
const {parts, extension} = splitAroundExtension(`asdf.${ext}/blah`)
expect(parts).toStrictEqual(['asdf', '/blah'])
expect(extension).toStrictEqual(`.${ext}`)
}
expect(() => {
splitAroundExtension(`asdf.obj/blah`)
}).toThrow(FilenameParseError)
})
})