-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles.test.js
More file actions
34 lines (27 loc) · 923 Bytes
/
files.test.js
File metadata and controls
34 lines (27 loc) · 923 Bytes
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
'use strict'
const p = require('path')
const assert = require('chai').assert
const pkg = require('../package')
const source = require('../src')
const files = source.files
const name = pkg.name
describe('files', () => {
describe('path', () => {
it('should return the normalized path of the given path', () => {
assert.strictEqual(files.path('a//../a'), 'a')
})
})
describe('root', () => {
it('should return the root directory of the project, when called without arguments', () => {
const root = files.root()
const dir = p.basename(root)
assert.strictEqual(dir, name)
})
it('should return the path relative to the root directory of the project, when passed a path', () => {
const path = files.root('/src')
const parts = path.split(p.sep)
const dir = parts.slice(parts.length - 2).join('/')
assert.strictEqual(dir, `${name}/src`)
})
})
})