Skip to content

Commit

Permalink
Fix test case finnally
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jan 8, 2018
1 parent 5af4b82 commit 9666d03
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/components/Authorized/CheckPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
return target;
}
// 数组倄理
if (authority.constructor.name === 'Array') {
if (authority.includes(currentAuthority)) {
if (Array.isArray(authority)) {
if (authority.indexOf(currentAuthority) >= 0) {
return target;
}
return Exception;
}

// string 倄理
if (authority.constructor.name === 'String') {
if (typeof authority === 'string') {
if (authority === currentAuthority) {
return target;
}
Expand All @@ -39,7 +39,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
}

// Function 倄理
if (authority.constructor.name === 'Function') {
if (typeof authority === 'function') {
try {
const bool = authority();
if (bool) {
Expand Down
9 changes: 9 additions & 0 deletions src/e2e/home.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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>');
});
});
7 changes: 6 additions & 1 deletion src/e2e/login.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ describe('Login', () => {
let page;
beforeEach(() => {
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 () => {
Expand Down

0 comments on commit 9666d03

Please sign in to comment.