Skip to content

Commit

Permalink
chore(test): moved to typescript migrate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Sep 29, 2018
1 parent 6e9f833 commit fd5492b
Show file tree
Hide file tree
Showing 78 changed files with 1,107 additions and 1,037 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -41,7 +41,8 @@
"travis:integration": "npm run build && npm run test && npm run reportCoverage",
"travis:lint": "lerna bootstrap && npm run build && npm run lint && npm run tslint && npm run bundlesize",
"tslint": "tslint -c tslint.json \"packages/**/*.ts\"",
"watch": "npm run build && tsc -w"
"watch": "npm run build && tsc -w",
"test:local": "jest --watch"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -69,7 +70,7 @@
"transform": {
"^.+\\.(ts)?$": "ts-jest"
},
"testRegex": "/__tests__/.*\\.(js|ts)$",
"testRegex": "/__tests__/.*\\.(test.js|test.ts)$",
"moduleFileExtensions": [
"ts",
"js"
Expand Down
158 changes: 0 additions & 158 deletions packages/migrate/__snapshots__/migrate.test.js.snap

This file was deleted.

99 changes: 99 additions & 0 deletions packages/migrate/__tests__/__snapshots__/migrate.test.ts.snap
Expand Up @@ -57,3 +57,102 @@ module.exports = {
};
"
`;

exports[`transform should respect recast options 1`] = `
"
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.js$/,
use: [{
loader: \\"babel-loader\\",
}],
include: path.join(__dirname, 'src')
}]
},
resolve: {
modules: ['node_modules', path.resolve('/src')],
},
plugins: [new webpack.LoaderOptionsPlugin({
debug: true,
})],
optimization: {
minimize: true,
}
};
"
`;

exports[`transform should transform only using specified transformations 1`] = `
"
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.js$/,
use: [{
loader: 'babel-loader'
}],
include: path.join(__dirname, 'src')
}]
},
resolve: {
root: path.resolve('/src'),
modules: ['node_modules']
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin()
],
debug: true
};
"
`;

exports[`transform should transform using all transformations 1`] = `
"
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.js$/,
use: [{
loader: 'babel-loader'
}],
include: path.join(__dirname, 'src')
}]
},
resolve: {
modules: ['node_modules', path.resolve('/src')]
},
plugins: [new webpack.LoaderOptionsPlugin({
debug: true
})],
optimization: {
minimize: true
}
};
"
`;
42 changes: 23 additions & 19 deletions packages/migrate/__tests__/migrate.test.ts
Expand Up @@ -30,30 +30,34 @@ module.exports = {
`;

describe("transform", () => {
it("should not transform if no transformations defined", async () => {
transform(input, []).then((output) => {
expect(output).toMatchSnapshot(input);
});
it("should not transform if no transformations defined", (done) => {
transform(input, []).then((output) => {
expect(output).toMatchSnapshot(input);
done();
});
});

it("should transform using all transformations", async () => {
transform(input).then((output) => {
expect(output).toMatchSnapshot();
});
it("should transform using all transformations", (done) => {
transform(input).then((output) => {
expect(output).toMatchSnapshot();
done();
});
});

it("should transform only using specified transformations", async () => {
transform(input, [transformations.loadersTransform]).then((output) => {
expect(output).toMatchSnapshot();
});
it("should transform only using specified transformations", (done) => {
transform(input, [transformations.loadersTransform]).then((output) => {
expect(output).toMatchSnapshot();
done();
});
});

it("should respect recast options", async () => {
transform(input, undefined, {
quote: "double",
trailingComma: true,
}).then((output) => {
expect(output).toMatchSnapshot();
});
it("should respect recast options", (done) => {
transform(input, undefined, {
quote: "double",
trailingComma: true,
}).then((output) => {
expect(output).toMatchSnapshot();
done();
});
});
});

0 comments on commit fd5492b

Please sign in to comment.