Commit 9666d03b authored by afc163's avatar afc163

Fix test case finnally

parent 5af4b82e
...@@ -16,15 +16,15 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { ...@@ -16,15 +16,15 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
return target; return target;
} }
// 数组倄理 // 数组倄理
if (authority.constructor.name === 'Array') { if (Array.isArray(authority)) {
if (authority.includes(currentAuthority)) { if (authority.indexOf(currentAuthority) >= 0) {
return target; return target;
} }
return Exception; return Exception;
} }
// string 倄理 // string 倄理
if (authority.constructor.name === 'String') { if (typeof authority === 'string') {
if (authority === currentAuthority) { if (authority === currentAuthority) {
return target; return target;
} }
...@@ -39,7 +39,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { ...@@ -39,7 +39,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
} }
// Function 倄理 // Function 倄理
if (authority.constructor.name === 'Function') { if (typeof authority === 'function') {
try { try {
const bool = authority(); const bool = authority();
if (bool) { if (bool) {
......
import Nightmare from 'nightmare';
describe('Homepage', () => {
it('it should have logo text', async () => {
const page = Nightmare().goto('http://localhost:8000');
const text = await page.wait('h1').evaluate(() => document.body.innerHTML).end();
expect(text).toContain('<h1>Ant Design Pro</h1>');
});
});
...@@ -4,7 +4,12 @@ describe('Login', () => { ...@@ -4,7 +4,12 @@ describe('Login', () => {
let page; let page;
beforeEach(() => { beforeEach(() => {
page = Nightmare(); page = Nightmare();
page.goto('http://localhost:8000/#/user/login'); page
.goto('http://localhost:8000/')
.evaluate(() => {
window.localStorage.setItem('antd-pro-authority', 'guest');
})
.goto('http://localhost:8000/#/user/login');
}); });
it('should login with failure', async () => { it('should login with failure', async () => {
......
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