forked from rollup/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.js
More file actions
33 lines (24 loc) · 901 Bytes
/
Copy pathform.js
File metadata and controls
33 lines (24 loc) · 901 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
/* eslint-disable consistent-return, global-require, import/no-dynamic-require */
process.chdir(__dirname);
const { readdirSync, readFileSync } = require('fs');
const test = require('ava');
const replace = require('../dist/rollup-plugin-replace.cjs.js');
const transformContext = {};
readdirSync('./fixtures/form').forEach((dir) => {
let config;
try {
config = require(`./fixtures/form/${dir}/_config.js`);
} catch (err) {
config = {};
}
test(`${dir}: ${config.description}`, (t) => {
const { transform } = replace(config.options);
const input = readFileSync(`fixtures/form/${dir}/input.js`, 'utf-8');
return Promise.resolve(
transform.call(transformContext, input, `${__dirname}/fixtures/form/${dir}/input.js`)
).then((transformed) => {
const actual = (transformed ? transformed.code : input).trim();
t.snapshot(actual);
});
});
});