-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
56 lines (45 loc) · 1.47 KB
/
index.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
const preset = require(`../`)
jest.mock(`../resolver`, () => jest.fn(moduleName => moduleName))
beforeEach(() => {
delete process.env.BABEL_ENV
})
describe(`babel-preset-gatsby-package`, () => {
describe(`in node mode`, () => {
it(`specifies the proper plugins`, () => {
const { plugins } = preset()
expect(plugins).toMatchSnapshot()
})
it(`specifies proper presets`, () => {
const { presets } = preset()
expect(presets).toMatchSnapshot()
})
it(`specifies proper presets for debugging`, () => {
const { presets } = preset(null, { debug: true })
expect(presets).toMatchSnapshot()
})
it(`can pass custom nodeVersion target`, () => {
const nodeVersion = `6.0`
const { presets } = preset(null, {
nodeVersion,
})
const [, opts] = presets.find(preset =>
[].concat(preset).includes(`@babel/preset-env`)
)
expect(opts.targets.node).toBe(nodeVersion)
})
})
describe(`in browser mode`, () => {
it(`specifies the proper plugins`, () => {
const { plugins } = preset(null, { browser: true })
expect(plugins).toMatchSnapshot()
})
it(`specifies proper presets`, () => {
const { presets } = preset(null, { browser: true })
expect(presets).toMatchSnapshot()
})
it(`specifies proper presets for debugging`, () => {
const { presets } = preset(null, { browser: true, debug: true })
expect(presets).toMatchSnapshot()
})
})
})