-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
41 lines (34 loc) · 1.14 KB
/
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
const test = require('ava')
const {
getFolderPath,
getFileName,
shouldFlip,
flipFileName,
removeInputFolderFromPath,
} = require('./src/util')
const fullPath1 = 'sprites/hello.png'
const fullPath2 = 'sprites/subfolder/hello.png'
const fullPathFlip = 'sprites/subfolder/hello-right.png'
test('getFolderPath', t => {
t.is(getFolderPath(fullPath1), 'sprites')
t.is(getFolderPath(fullPath2), 'sprites/subfolder')
})
test('getFileName', t => {
t.is(getFileName(fullPath1), 'hello')
t.is(getFileName(fullPath2), 'hello')
})
test('shouldFlip', t => {
t.is(shouldFlip(fullPath2), false)
t.is(shouldFlip(fullPathFlip), true)
})
test('flipFileName', t => {
t.is(flipFileName(getFileName(fullPath2)), 'hello')
t.is(flipFileName(getFileName(fullPathFlip)), 'hello-left')
})
test('removeInitialFolderFromPath', t => {
const inputFolder = 'asset/sprite'
const fullSourcePath1 = 'asset/sprite/hello.png'
const fullSourcePath2 = 'asset/sprite/subfolder/hello.png'
t.is(removeInputFolderFromPath(inputFolder, getFolderPath(fullSourcePath1)), '')
t.is(removeInputFolderFromPath(inputFolder, getFolderPath(fullSourcePath2)), '/subfolder')
})