Skip to content

Commit

Permalink
tests(migrate): moved to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored and dhruvdutt committed Nov 4, 2018
1 parent aa80327 commit 5a34a88
Show file tree
Hide file tree
Showing 110 changed files with 455 additions and 464 deletions.
10 changes: 9 additions & 1 deletion packages/add/README.md
Expand Up @@ -10,17 +10,25 @@ This package contains the logic to add new properties in a webpack configuration
npm i -D webpack-cli @webpack-cli/add
```

or

```bash
yarn add --dev webpack-cli @webpack-cli/add
```

## Usage

To run the scaffolding instance programmatically, install it as a dependency. When using the package programmatically, one does not have to install webpack-cli.

### Node

```js
const add = require("@webpack-cli/add");
add();
```

### CLI (via `webpack-cli`)

```bash
npx webpack-cli add
```
```
15 changes: 7 additions & 8 deletions packages/add/index.ts
Expand Up @@ -9,15 +9,14 @@ import modifyConfigHelper from "@webpack-cli/utils/modify-config-helper";
* we're given on a generator
*
*/
const DEFAULT_WEBPACK_CONFIG_FILENAME: string = "webpack.config.js";

export default function add(...args: string[]): Function {
const DEFAULT_WEBPACK_CONFIG_FILENAME: string = "webpack.config.js";
const filePaths: string[] = args.slice(3);
let configFile: string = DEFAULT_WEBPACK_CONFIG_FILENAME;
if (filePaths.length) {
configFile = filePaths[0];
}

const filePaths: string[] = args.slice(3);
let configFile: string = DEFAULT_WEBPACK_CONFIG_FILENAME;
if (filePaths.length) {
configFile = filePaths[0];
}

return modifyConfigHelper("add", defaultGenerator, configFile);
return modifyConfigHelper("add", defaultGenerator, configFile);
}
6 changes: 6 additions & 0 deletions packages/migrate/bannerPlugin/__tests__/bannerPlugin.test.ts
@@ -0,0 +1,6 @@
import defineTest from "@webpack-cli/utils/defineTest";
import { join } from "path";

defineTest(join(__dirname, ".."), "bannerPlugin", "bannerPlugin-0");
defineTest(join(__dirname, ".."), "bannerPlugin", "bannerPlugin-1");
defineTest(join(__dirname, ".."), "bannerPlugin", "bannerPlugin-2");
7 changes: 0 additions & 7 deletions packages/migrate/bannerPlugin/bannerPlugin.test.js

This file was deleted.

@@ -0,0 +1,30 @@
import defineTest from "@webpack-cli/utils/defineTest";
import { join } from "path";

defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-0");
defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-1");
defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-2");
defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-3");
defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-4");
defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-5");
defineTest(
join(__dirname, ".."),
"commonsChunkPlugin",
"commonsChunkPlugin-6a",
);
defineTest(
join(__dirname, ".."),
"commonsChunkPlugin",
"commonsChunkPlugin-6b",
);
defineTest(
join(__dirname, ".."),
"commonsChunkPlugin",
"commonsChunkPlugin-6c",
);
defineTest(
join(__dirname, ".."),
"commonsChunkPlugin",
"commonsChunkPlugin-6d",
);
defineTest(join(__dirname, ".."), "commonsChunkPlugin", "commonsChunkPlugin-7");
15 changes: 0 additions & 15 deletions packages/migrate/commonsChunkPlugin/commonsChunkPlugin.test.js

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`extractTextPlugin transforms correctly 1`] = `
"const ExtractTextPlugin = require(\\"extract-text-webpack-plugin\\");
module.exports = {
module: {
rules: [
{
test: /\\\\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
}
]
},
plugins: [new ExtractTextPlugin(\\"styles.css\\")]
};
"
`;
@@ -0,0 +1,13 @@
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract("style-loader", "css-loader")
}
]
},
plugins: [new ExtractTextPlugin("styles.css")]
};
@@ -0,0 +1,4 @@
import defineTest from "@webpack-cli/utils/defineTest";
import { join } from "path";

defineTest(join(__dirname, ".."), "extractTextPlugin");
5 changes: 0 additions & 5 deletions packages/migrate/extractTextPlugin/extractTextPlugin.test.js

This file was deleted.

@@ -0,0 +1,22 @@
import defineTest from "@webpack-cli/utils/defineTest";
import { join } from "path";
defineTest(
join(__dirname, ".."),
"loaderOptionsPlugin",
"loaderOptionsPlugin-0",
);
defineTest(
join(__dirname, ".."),
"loaderOptionsPlugin",
"loaderOptionsPlugin-1",
);
defineTest(
join(__dirname, ".."),
"loaderOptionsPlugin",
"loaderOptionsPlugin-2",
);
defineTest(
join(__dirname, ".."),
"loaderOptionsPlugin",
"loaderOptionsPlugin-3",
);

This file was deleted.

@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`loaders transforms correctly using "loaders-0" data 1`] = `
"export default [
"module.exports = [
{
module: {
rules: [
Expand Down Expand Up @@ -118,7 +118,7 @@ exports[`loaders transforms correctly using "loaders-0" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-1" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [
{
Expand All @@ -142,7 +142,7 @@ exports[`loaders transforms correctly using "loaders-1" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-2" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [
{
Expand All @@ -163,7 +163,7 @@ exports[`loaders transforms correctly using "loaders-2" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-3" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [
{
Expand All @@ -181,7 +181,7 @@ exports[`loaders transforms correctly using "loaders-3" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-4" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [
{
Expand All @@ -199,7 +199,7 @@ exports[`loaders transforms correctly using "loaders-4" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-5" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [{
use: [{
Expand All @@ -220,7 +220,7 @@ exports[`loaders transforms correctly using "loaders-5" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-6" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [{
use: [{
Expand All @@ -241,7 +241,7 @@ exports[`loaders transforms correctly using "loaders-6" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-7" data 1`] = `
"export default {
"module.exports = {
module: {
rules: [
{
Expand All @@ -264,27 +264,26 @@ exports[`loaders transforms correctly using "loaders-7" data 1`] = `
`;

exports[`loaders transforms correctly using "loaders-8" data 1`] = `
"import * as path from \\"path\\";
module.exports = {
module: {
rules: [
{
include: path.join(__dirname, \\"src\\"),
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader',
"module.exports = {
module: {
rules: [
{
include: path.join(__dirname, \\"src\\"),
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
string: 'test123'
}
}],
test: /\\\\.js$/,
},
],
},
options: {
modules: true,
importLoaders: 1,
string: 'test123'
}
}],
test: /\\\\.js$/
}
]
}
};
"
`;
@@ -1,4 +1,4 @@
export default [
module.exports = [
{
module: {
loaders: [
Expand Down
@@ -1,4 +1,4 @@
export default {
module.exports = {
module: {
loaders: [
{
Expand Down
@@ -1,4 +1,4 @@
export default {
module.exports = {
module: {
loaders: [
{
Expand Down
@@ -1,4 +1,4 @@
export default {
module.exports = {
module: {
preLoaders: [
{
Expand Down
@@ -1,4 +1,4 @@
export default {
module.exports = {
module: {
postLoaders: [
{
Expand Down
@@ -1,4 +1,4 @@
export default {
module.exports = {
module: {
loaders: [
{
Expand Down
@@ -1,4 +1,4 @@
export default {
module.exports = {
module: {
loaders: [
{
Expand Down

0 comments on commit 5a34a88

Please sign in to comment.