diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index e9664550c923d0a2dfc828e4b42ff8332a798112..c1d6647dd679b57736cf68246fb02592e9c4b800 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -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; } @@ -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) { diff --git a/src/e2e/home.e2e.js b/src/e2e/home.e2e.js new file mode 100644 index 0000000000000000000000000000000000000000..61b0cd83a89568f5a88364c15196f2ff5b1064e4 --- /dev/null +++ b/src/e2e/home.e2e.js @@ -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('