Skip to content

Commit

Permalink
fix all test (umijs#6454)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 authored Apr 21, 2021
1 parent d8300fd commit 0867356
Show file tree
Hide file tree
Showing 167 changed files with 729 additions and 567 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: yarn --ignore-engines
- run: yarn build
- run: yarn run tsc --noEmit
- run: yarn test --detectOpenHandles --maxWorkers=4 --forceExit
env:
CI: true
Expand Down
2 changes: 1 addition & 1 deletion e2e/wrappers/wrappers/bar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export default (props) => {
export default (props: React.PropsWithChildren<{}>) => {
return (
<div>
<h1>bar</h1>
Expand Down
2 changes: 1 addition & 1 deletion e2e/wrappers/wrappers/foo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export default (props) => {
export default (props: React.PropsWithChildren<{}>) => {
return (
<div>
<h1>foo</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default (babel) => {
visitor: {
// @ts-ignore
ExportDefaultDeclaration: {
enter(path, state) {
enter(path: any, state: any) {
const def = path.node.declaration;
const { cwd, filename } = state.file.opts;
const relativePath = relative(cwd, filename);
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/alias/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default {
nodeModulesTransform: {
type: 'none',
},
}
};
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/alias/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain(`var a = 'react';`);
}
};
1 change: 0 additions & 1 deletion packages/bundler-webpack/src/fixtures/alias/react.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

const a = 'react';
export default a;
3 changes: 1 addition & 2 deletions packages/bundler-webpack/src/fixtures/autoprefixer/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export default {
targets: {
ie: 10,
},
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexCSS }: IExpectOpts) => {
expect(indexCSS).toContain(`.a { display: -ms-flexbox; display: flex; }`);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export default {
webpackConfig.resolve.alias.set('react', './react.ts');
return webpackConfig;
},
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain(`var a = 'react';`);
}
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

const a = 'react';
export default a;
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export default {
webpackConfig.resolve.alias.set('react', './react.ts');
return webpackConfig;
},
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain(`var a = 'react';`);
}
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

const a = 'react';
export default a;
10 changes: 5 additions & 5 deletions packages/bundler-webpack/src/fixtures/copy/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export default {
'b.ts',
{
from: 'c.ts',
to: ''
to: '',
},
{
from: 'utils/d.ts',
to: ''
}
]
}
to: '',
},
],
};
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/copy/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export default ({ files }: IExpectOpts) => {
expect(files).toContain(`index.js`);
expect(files).toContain(`c.ts`);
expect(files).toContain(`d.ts`);
}
};
5 changes: 2 additions & 3 deletions packages/bundler-webpack/src/fixtures/css-alias/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export default {
alias: {
bbb: require.resolve('./bar.css'),
}
}
},
};
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/css-alias/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export default ({ indexCSS }: IExpectOpts) => {
expect(indexCSS).toContain(`.foo {`);
expect(indexCSS).toContain(`.bar {`);
expect(indexCSS).toContain(`.b {`);
}
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
cssModulesTypescriptLoader: {}
}
cssModulesTypescriptLoader: {},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IExpectOpts } from '../types';
import * as ts from 'typescript';
import {resolve} from 'path';
import { resolve } from 'path';
import { createDebug } from '@umijs/utils';

const debug = createDebug('umi:dtstest');
Expand All @@ -11,16 +11,19 @@ const typeCheckFile = (files: string[]): boolean => {
let diagnostic: readonly ts.Diagnostic[] = [];
for (const sourceFile of program.getSourceFiles()) {
if (!sourceFile.isDeclarationFile) {
diagnostic = [...diagnostic, ...program.getSemanticDiagnostics(sourceFile)];
diagnostic = [
...diagnostic,
...program.getSemanticDiagnostics(sourceFile),
];
}
}

debug('diagnostic: ', diagnostic);
return diagnostic.length === 0;
}
};

export default ({ indexCSS, files, cwd }: IExpectOpts) => {
expect(indexCSS).toContain(`.a___`);
expect(indexCSS).toContain(`.test___`);
expect(typeCheckFile([resolve(cwd, 'index.ts')])).toBe(true);
}
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from './style.less'
import styles2 from './style2.css'
import styles from './style.less';
import styles2 from './style2.css';

const classname = styles.a
const classname = styles.a;

const classname2 = styles2.test
const classname2 = styles2.test;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.a {
color: white;
color: white;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export default ({ indexCSS, indexCSSMap, indexJS }: IExpectOpts) => {
expect(indexCSSMap).toContain('css-modules/b.css');

expect(indexJS).toMatch(/__webpack_require__\.n\(_empty_less_modules.+\)/i);
}
};
4 changes: 2 additions & 2 deletions packages/bundler-webpack/src/fixtures/define/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
FOO: '1',
'a.FOO': '2',
'process.env.FOO': '3',
}
}
},
};
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/define/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain(`console.log("2");`);
expect(indexJS).toContain(`console.log("3");`);
expect(indexJS).toContain(`console.log("test");`);
}
};
3 changes: 2 additions & 1 deletion packages/bundler-webpack/src/fixtures/define/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

//@ts-ignore
console.log(FOO);
//@ts-ignore
console.log(a.FOO);
console.log(process.env.FOO);
console.log(process.env.NODE_ENV);
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

export default {
nodeModulesTransform: {
type: 'all',
exclude: ['foo'],
}
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export default ({ indexJS }: IExpectOpts) => {
// exclude
expect(indexJS).toContain(`const react = 'react';`);
expect(indexJS).toContain(`const foo = 'foo';`);
}
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

export default {
nodeModulesTransform: {
type: 'none',
exclude: ['react-intl'],
}
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export default ({ indexJS }: IExpectOpts) => {
// not transform
expect(indexJS).toContain(`const react = 'react';`);
expect(indexJS).toContain(`const foo = 'foo';`);
}
};
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

console.log('a');
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

console.log('b');
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export default {
dynamicImport: false,
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { IExpectOpts } from '../types';
export default ({ indexJS, files }: IExpectOpts) => {
expect(indexJS).toContain(`console.log('a');`);
expect(indexJS).toContain(`console.log('b');`);
}
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//@ts-ignore
import('./a');
import(/* webpackChunkName: "b" */'./b');
//@ts-ignore
import(/* webpackChunkName: "b" */ './b');
1 change: 0 additions & 1 deletion packages/bundler-webpack/src/fixtures/dynamic-import/a.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

console.log('a');
1 change: 0 additions & 1 deletion packages/bundler-webpack/src/fixtures/dynamic-import/b.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

console.log('b');
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

export default {
devtool: false,
dynamicImport: true,
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export default ({ indexJS, files }: IExpectOpts) => {
expect(files).toEqual(['0.js', 'b.js', 'index.js']);
expect(indexJS).toContain(`__webpack_require__.e(/*! import() */ 0)`);
expect(indexJS).toContain(`__webpack_require__.e(/*! import() | b */ "b")`);
}
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// @ts-ignore
import('./a');
import(/* webpackChunkName: "b" */'./b');
// @ts-ignore
import(/* webpackChunkName: "b" */ './b');
4 changes: 2 additions & 2 deletions packages/bundler-webpack/src/fixtures/externals/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
externals: {
react: 'React',
}
}
},
};
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/externals/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain(`module.exports = React;`);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { join } from 'path';

export default {
nodeModulesTransform: {
type: 'none'
type: 'none',
},
extraBabelIncludes: [
join(__dirname, '../.extraBabelIncludes'),
'foo',
'bar',
],
}
extraBabelIncludes: [join(__dirname, '../.extraBabelIncludes'), 'foo', 'bar'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain('var bar = 1;');
expect(indexJS).toContain('var foo = 1;');
expect(indexJS).toContain('var hoo = 1;');
}
};
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.a { overflow-scrolling: scroll; }
.a {
overflow-scrolling: scroll;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const plugin = require('./plugin');

export default {
extraPostCSSPlugins: [
plugin(),
]
}
extraPostCSSPlugins: [plugin()],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexCSS }: IExpectOpts) => {
expect(indexCSS).toContain('-webkit-overflow-scrolling: touch;');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ var postcss = require('postcss');

// custom postcss plugin
module.exports = postcss.plugin('postcss-test-plugin', () => {
return (root) => {
root.walkRules((rule) => {
rule.walkDecls(/^overflow-?/, (decl) => {
return (root: any) => {
root.walkRules((rule: any) => {
rule.walkDecls(/^overflow-?/, (decl: any) => {
console.log('decl.value ', decl.value);
if (decl.value === 'scroll') {
var hasTouch = rule.some((i) => {
var hasTouch = rule.some((i: any) => {
return i.prop === '-webkit-overflow-scrolling';
});
if (!hasTouch) {
rule.append({
prop: '-webkit-overflow-scrolling',
value: 'touch'
value: 'touch',
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/font/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { IExpectOpts } from '../types';
export default ({ indexCSS }: IExpectOpts) => {
expect(indexCSS).toContain(`src: url(./static/a.`);
expect(indexCSS).toContain(`.eot);`);
}
};
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/fixtures/json/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { IExpectOpts } from '../types';

export default ({ indexJS }: IExpectOpts) => {
expect(indexJS).toContain(`JSON.parse("{\\"foo\\":\\"react\\"}");`);
}
};
5 changes: 2 additions & 3 deletions packages/bundler-webpack/src/fixtures/less-alias/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export default {
alias: {
bbb: require.resolve('./mixin.less'),
}
}
},
};
Loading

0 comments on commit 0867356

Please sign in to comment.