-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdef-key-builder.unit.test.js
41 lines (34 loc) · 1.11 KB
/
def-key-builder.unit.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
39
40
41
/* eslint-env jest */
const defKeyBuilder = require('./def-key-builder')
describe('tokenize', () => {
test('Without base dir', () => {
const key = defKeyBuilder.tokenize('/base/path/to/file')
expect(key).toBe('base,path,to,file')
})
test('With base dir', () => {
const key = defKeyBuilder.tokenize('/base/path/to/file', { baseDir: '/base/path' })
expect(key).toBe('to,file')
})
test('With custom token', () => {
const key = defKeyBuilder.tokenize('/base/path/to/file', { token: '*' })
expect(key).toBe('base*path*to*file')
})
})
describe('Misc.', () => {
test('camelCase', () => {
const key = defKeyBuilder.camelCase('/base/path/to/file')
expect(key).toBe('basePathToFile')
})
test('kebabCase', () => {
const key = defKeyBuilder.kebabCase('/base/path/to/file')
expect(key).toBe('base-path-to-file')
})
test('snakeCase', () => {
const key = defKeyBuilder.snakeCase('/base/path/to/file')
expect(key).toBe('base_path_to_file')
})
test('titleize', () => {
const key = defKeyBuilder.titleize('/base/path/to/file')
expect(key).toBe('BasePathToFile')
})
})