Skip to content

Commit

Permalink
test: add test for v0.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bailicangdu committed Jan 14, 2022
1 parent c18acbe commit 49eccf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/__tests__/create_app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,26 @@ describe('create_app', () => {
})
})

// 分支覆盖之prefetchResolve为空
test('coverage: undefined prefetchResolve', async () => {
const microAppElement20 = document.createElement('micro-app')
microAppElement20.setAttribute('name', 'test-app20')
microAppElement20.setAttribute('url', `http://127.0.0.1:${ports.create_app}/common`)

appCon.appendChild(microAppElement20)
appInstanceMap.get('test-app20')!.isPrefetch = true

const mountedHandler = jest.fn()
microAppElement20.addEventListener('mounted', mountedHandler)

await new Promise((resolve) => {
setTimeout(() => {
expect(mountedHandler).not.toBeCalled()
resolve(true)
}, 100)
})
})

// 测试getActiveApps方法
test('test getActiveApps method', async () => {
// 因为上面已经执行unmountAllApps卸载了所有应用,所以这里长度为0
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/micro_app_element.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('micro_app_element', () => {

await new Promise((resolve) => {
microAppElement2.addEventListener('mounted', () => {
expect(appInstanceMap.size).toBe(3)
// expect(appInstanceMap.size).toBe(3) // 由于预加载执行时机不确定,appInstanceMap.size也不确定
resolve(true)
}, false)
})
Expand Down

0 comments on commit 49eccf0

Please sign in to comment.