forked from Janlaywss/micro-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
989746e
commit 679bc13
Showing
22 changed files
with
269 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ install: | |
script: | ||
- npm run test:coverage | ||
- ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
- [Gitter群聊](https://gitter.im/zoe-community/zoe-room) | ||
- [Gitter群聊](https://gitter.im/microzoe/micro-app) | ||
- [GitHub讨论组](https://github.com/micro-zoe/micro-app/discussions) | ||
- [BUG反馈](https://github.com/micro-zoe/micro-app/issues) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,49 @@ | ||
/* eslint-disable promise/param-names */ | ||
import './common' | ||
import { commonStartEffect, releaseAllEffect, ports } from './common' | ||
import microApp from '..' | ||
import preFetch from '../prefetch' | ||
import { globalLinks } from '../source/links' | ||
import { globalScripts } from '../source/scripts' | ||
|
||
global.console.warn = jest.fn() | ||
global.console.error = jest.fn() | ||
describe('prefetch', () => { | ||
// let appCon: Element | ||
beforeAll(() => { | ||
commonStartEffect(ports.prefetch) | ||
// appCon = document.querySelector('#app-container')! | ||
|
||
test('coverage branch for prefetch', async () => { | ||
microApp.start() | ||
microApp.start({ | ||
globalAssets: { | ||
js: [ | ||
`http://127.0.0.1:${ports.prefetch}/common/script1.js`, | ||
`http://127.0.0.1:${ports.prefetch}/common/script1.js`, | ||
'http://not-exist.com/xxx.js' | ||
], | ||
css: [ | ||
`http://127.0.0.1:${ports.prefetch}/common/link1.css`, | ||
`http://127.0.0.1:${ports.prefetch}/common/link1.css`, | ||
'http://not-exist.com/xxx.css' | ||
], | ||
} | ||
}) | ||
}) | ||
|
||
afterAll(() => { | ||
return releaseAllEffect() | ||
}) | ||
|
||
// sepecial case | ||
test('coverage branch for prefetch', async () => { | ||
preFetch(123 as any) // 非法的入参 | ||
preFetch([{ name: 'test-app1', url: 'http://www.micro-app-test.com' }]) // 正常入参 | ||
await new Promise((reslove) => { | ||
setTimeout(() => { | ||
reslove(true) | ||
}, 100) | ||
}) | ||
}) | ||
|
||
preFetch(123 as any) // 非法的入参 | ||
preFetch([{ name: 'test-app1', url: 'http://www.micro-app-test.com' }]) // 正常入参 | ||
await new Promise((reslove) => { | ||
setTimeout(() => { | ||
reslove(true) | ||
}, 100) | ||
test('globalAssets should work normal', async () => { | ||
expect(globalLinks.get(`http://127.0.0.1:${ports.prefetch}/common/link1.css`)).not.toBeNull() | ||
expect(globalScripts.get(`http://127.0.0.1:${ports.prefetch}/common/script1.js`)).not.toBeNull() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.