Commit 3cfbae3b authored by jim's avatar jim Committed by ι™ˆεΈ…

fix ci

parent 4bec5248
const path = require('path');
module.exports = {
plugins: [
[
'babel-plugin-module-resolver',
'module-resolver',
{
alias: {
components: './src/components',
components: path.join(__dirname, './src/components'),
},
},
],
[
'import',
{
libraryName: 'antd',
style: true, // or 'css'
},
],
],
};
......@@ -75,14 +75,14 @@
"pro-download": "^1.0.1",
"redbox-react": "^1.5.0",
"regenerator-runtime": "^0.11.1",
"roadhog": "^2.3.0",
"roadhog-api-doc": "^1.0.2",
"roadhog": "^2.4.1",
"roadhog-api-doc": "^1.0.3",
"stylelint": "^8.4.0",
"stylelint-config-prettier": "^3.0.4",
"stylelint-config-standard": "^18.0.0"
},
"optionalDependencies": {
"puppeteer": "^1.1.1"
"puppeteer": "^1.4.0"
},
"lint-staged": {
"**/*.{js,jsx,less}": [
......
import { urlToList } from '../_utils/pathTools';
import { getFlatMenuKeys, getMeunMatchKeys } from './SiderMenu';
import { getFlatMenuKeys, getMenuMatchKeys } from './SiderMenu';
const menu = [{
const menu = [
{
path: '/dashboard',
children: [{
children: [
{
path: '/dashboard/name',
}],
}, {
},
],
},
{
path: '/userinfo',
children: [{
children: [
{
path: '/userinfo/:id',
children: [{
children: [
{
path: '/userinfo/:id/info',
}],
}],
}];
},
],
},
],
},
];
const flatMenuKeys = getFlatMenuKeys(menu);
describe('test convert nested menu to flat menu', () => {
it('simple menu', () => {
expect(flatMenuKeys).toEqual(
['/dashboard', '/dashboard/name', '/userinfo', '/userinfo/:id', '/userinfo/:id/info']
);
})
expect(flatMenuKeys).toEqual([
'/dashboard',
'/dashboard/name',
'/userinfo',
'/userinfo/:id',
'/userinfo/:id/info',
]);
});
});
describe('test menu match', () => {
it('simple path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/dashboard'))).toEqual(['/dashboard']);
expect(getMenuMatchKeys(flatMenuKeys, urlToList('/dashboard'))).toEqual(['/dashboard']);
});
it('error path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/dashboardname'))).toEqual([]);
expect(getMenuMatchKeys(flatMenuKeys, urlToList('/dashboardname'))).toEqual([]);
});
it('Secondary path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/dashboard/name'))).toEqual(['/dashboard', '/dashboard/name']);
expect(getMenuMatchKeys(flatMenuKeys, urlToList('/dashboard/name'))).toEqual([
'/dashboard',
'/dashboard/name',
]);
});
it('Parameter path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/userinfo/2144'))).toEqual(['/userinfo', '/userinfo/:id']);
expect(getMenuMatchKeys(flatMenuKeys, urlToList('/userinfo/2144'))).toEqual([
'/userinfo',
'/userinfo/:id',
]);
});
it('three parameter path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/userinfo/2144/info'))).toEqual(['/userinfo', '/userinfo/:id', '/userinfo/:id/info']);
expect(getMenuMatchKeys(flatMenuKeys, urlToList('/userinfo/2144/info'))).toEqual([
'/userinfo',
'/userinfo/:id',
'/userinfo/:id/info',
]);
});
});
......@@ -2,9 +2,9 @@ import puppeteer from 'puppeteer';
describe('Homepage', () => {
it('it should have logo text', async () => {
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.goto('http://localhost:8000');
await page.goto('http://localhost:8000', { waitUntil: 'networkidle2' });
await page.waitForSelector('h1');
const text = await page.evaluate(() => document.body.innerHTML);
expect(text).toContain('<h1>Ant Design Pro</h1>');
......
......@@ -5,12 +5,12 @@ describe('Login', () => {
let page;
beforeAll(async () => {
browser = await puppeteer.launch();
browser = await puppeteer.launch({ args: ['--no-sandbox'] });
});
beforeEach(async () => {
page = await browser.newPage();
await page.goto('http://localhost:8000/#/user/login');
await page.goto('http://localhost:8000/#/user/login', { waitUntil: 'networkidle2' });
await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest'));
});
......
......@@ -30,8 +30,9 @@ startServer.stdout.on('data', data => {
const testCmd = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['test'], {
stdio: 'inherit',
});
testCmd.on('exit', () => {
testCmd.on('exit', code => {
startServer.kill();
process.exit(code);
});
}
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment