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

fix ci

parent 4bec5248
const path = require('path');
module.exports = { module.exports = {
plugins: [ plugins: [
[ [
'babel-plugin-module-resolver', 'module-resolver',
{ {
alias: { alias: {
components: './src/components', components: path.join(__dirname, './src/components'),
}, },
}, },
], ],
[
'import',
{
libraryName: 'antd',
style: true, // or 'css'
},
],
], ],
}; };
\ No newline at end of file
...@@ -75,14 +75,14 @@ ...@@ -75,14 +75,14 @@
"pro-download": "^1.0.1", "pro-download": "^1.0.1",
"redbox-react": "^1.5.0", "redbox-react": "^1.5.0",
"regenerator-runtime": "^0.11.1", "regenerator-runtime": "^0.11.1",
"roadhog": "^2.3.0", "roadhog": "^2.4.1",
"roadhog-api-doc": "^1.0.2", "roadhog-api-doc": "^1.0.3",
"stylelint": "^8.4.0", "stylelint": "^8.4.0",
"stylelint-config-prettier": "^3.0.4", "stylelint-config-prettier": "^3.0.4",
"stylelint-config-standard": "^18.0.0" "stylelint-config-standard": "^18.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"puppeteer": "^1.1.1" "puppeteer": "^1.4.0"
}, },
"lint-staged": { "lint-staged": {
"**/*.{js,jsx,less}": [ "**/*.{js,jsx,less}": [
......
import { urlToList } from '../_utils/pathTools'; import { urlToList } from '../_utils/pathTools';
import { getFlatMenuKeys, getMeunMatchKeys } from './SiderMenu'; import { getFlatMenuKeys, getMenuMatchKeys } from './SiderMenu';
const menu = [{ const menu = [
path: '/dashboard', {
children: [{ path: '/dashboard',
path: '/dashboard/name', children: [
}], {
}, { path: '/dashboard/name',
path: '/userinfo', },
children: [{ ],
path: '/userinfo/:id', },
children: [{ {
path: '/userinfo/:id/info', path: '/userinfo',
}], children: [
}], {
}]; path: '/userinfo/:id',
children: [
{
path: '/userinfo/:id/info',
},
],
},
],
},
];
const flatMenuKeys = getFlatMenuKeys(menu); const flatMenuKeys = getFlatMenuKeys(menu);
describe('test convert nested menu to flat menu', () => { describe('test convert nested menu to flat menu', () => {
it('simple menu', () => { it('simple menu', () => {
expect(flatMenuKeys).toEqual( expect(flatMenuKeys).toEqual([
['/dashboard', '/dashboard/name', '/userinfo', '/userinfo/:id', '/userinfo/:id/info'] '/dashboard',
); '/dashboard/name',
}) '/userinfo',
'/userinfo/:id',
'/userinfo/:id/info',
]);
});
}); });
describe('test menu match', () => { describe('test menu match', () => {
it('simple path', () => { it('simple path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/dashboard'))).toEqual(['/dashboard']); expect(getMenuMatchKeys(flatMenuKeys, urlToList('/dashboard'))).toEqual(['/dashboard']);
}); });
it('error path', () => { it('error path', () => {
expect(getMeunMatchKeys(flatMenuKeys, urlToList('/dashboardname'))).toEqual([]); expect(getMenuMatchKeys(flatMenuKeys, urlToList('/dashboardname'))).toEqual([]);
}); });
it('Secondary path', () => { 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', () => { 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', () => { 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'; ...@@ -2,9 +2,9 @@ import puppeteer from 'puppeteer';
describe('Homepage', () => { describe('Homepage', () => {
it('it should have logo text', async () => { 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(); const page = await browser.newPage();
await page.goto('http://localhost:8000'); await page.goto('http://localhost:8000', { waitUntil: 'networkidle2' });
await page.waitForSelector('h1'); await page.waitForSelector('h1');
const text = await page.evaluate(() => document.body.innerHTML); const text = await page.evaluate(() => document.body.innerHTML);
expect(text).toContain('<h1>Ant Design Pro</h1>'); expect(text).toContain('<h1>Ant Design Pro</h1>');
......
...@@ -5,12 +5,12 @@ describe('Login', () => { ...@@ -5,12 +5,12 @@ describe('Login', () => {
let page; let page;
beforeAll(async () => { beforeAll(async () => {
browser = await puppeteer.launch(); browser = await puppeteer.launch({ args: ['--no-sandbox'] });
}); });
beforeEach(async () => { beforeEach(async () => {
page = await browser.newPage(); 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')); await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest'));
}); });
......
...@@ -30,8 +30,9 @@ startServer.stdout.on('data', data => { ...@@ -30,8 +30,9 @@ startServer.stdout.on('data', data => {
const testCmd = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['test'], { const testCmd = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['test'], {
stdio: 'inherit', stdio: 'inherit',
}); });
testCmd.on('exit', () => { testCmd.on('exit', code => {
startServer.kill(); 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