forked from ben-rogerson/twin.macro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.test.js
34 lines (32 loc) · 961 Bytes
/
plugin.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
const pluginTester = require('babel-plugin-tester').default
const plugin = require('babel-plugin-macros')
const path = require('path')
const glob = require('glob-all')
const fs = require('fs')
const configFile = file => `${path.dirname(file)}/config.json`
pluginTester({
plugin,
pluginName: 'twin.macro',
babelOptions: {
filename: __filename,
babelrc: true,
},
snapshot: true,
tests: glob
.sync(['__fixtures__/**/*.js', '!__fixtures__/**/*.config.js'])
.map(file => ({
title: path.basename(file),
code: fs.readFileSync(file, 'utf8'),
pluginOptions: {
twin: {
...(fs.existsSync(
path.join(path.dirname(file), 'tailwind.config.js')
) && {
config: path.join(path.dirname(file), 'tailwind.config.js'),
}),
...(fs.existsSync(configFile(file)) &&
JSON.parse(fs.readFileSync(configFile(file), 'utf8'))),
},
},
})),
})