/
migrate.test.ts
63 lines (58 loc) · 1.27 KB
/
migrate.test.ts
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
import { transform, transformations } from "../migrate";
const input = `
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
loaders: [{
test: /.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src')
}]
},
resolve: {
root: path.resolve('/src'),
modules: ['node_modules']
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin()
],
debug: true
};
`;
describe("transform", () => {
it("should not transform if no transformations defined", (done) => {
transform(input, []).then((output) => {
expect(output).toMatchSnapshot(input);
done();
});
});
it("should transform using all transformations", (done) => {
transform(input).then((output) => {
expect(output).toMatchSnapshot();
done();
});
});
it("should transform only using specified transformations", (done) => {
transform(input, [transformations.loadersTransform]).then((output) => {
expect(output).toMatchSnapshot();
done();
});
});
it("should respect recast options", (done) => {
transform(input, undefined, {
quote: "double",
trailingComma: true,
}).then((output) => {
expect(output).toMatchSnapshot();
done();
});
});
});