-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
68 lines (59 loc) · 1.76 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import path from 'path'
import test from 'ava'
import fn from '.'
const babelrcPath = path.resolve('fixture', 'babelrc', '.babelrc')
const babelrcJsPath = path.resolve('fixture', 'babelrcjs', '.babelrc.js')
const babelConfigJsPath = path.resolve(
'fixture',
'babelconfigjs',
'babel.config.js'
)
const pkgPath = path.resolve('fixture', 'pkg', 'package.json')
test('parse babel.config.js', async t => {
const cwd = path.join('fixture', 'babelconfigjs')
const { path: p, babel } = await fn({ cwd })
t.is(p, babelConfigJsPath)
t.snapshot(babel)
})
test('parse babel.config.js - sync', t => {
const cwd = path.join('fixture', 'babelconfigjs')
const { path: p, babel } = fn.sync({ cwd })
t.is(p, babelConfigJsPath)
t.snapshot(babel)
})
test('async', async t => {
const cwd = path.join('fixture', 'babelrc', 'app')
const { path: p, babel } = await fn({ cwd })
t.is(p, babelrcPath)
t.snapshot(babel)
})
test('sync', t => {
const cwd = path.join('fixture', 'babelrc', 'app')
const { path: p, babel } = fn.sync({ cwd })
t.is(p, babelrcPath)
t.snapshot(babel)
})
test('parse package.json', async t => {
const cwd = path.join('fixture', 'pkg')
const { path: p, babel } = await fn({ cwd })
t.is(p, pkgPath)
t.snapshot(babel)
})
test('parse package.json - sync', t => {
const cwd = path.join('fixture', 'pkg')
const { path: p, babel } = fn.sync({ cwd })
t.is(p, pkgPath)
t.snapshot(babel)
})
test('parse babelrc.js', async t => {
const cwd = path.join('fixture', 'babelrcjs')
const { path: p, babel } = await fn({ cwd })
t.is(p, babelrcJsPath)
t.snapshot(babel)
})
test('parse babelrc.js - sync', t => {
const cwd = path.join('fixture', 'babelrcjs')
const { path: p, babel } = fn.sync({ cwd })
t.is(p, babelrcJsPath)
t.snapshot(babel)
})