This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Showing
22 changed files
with
342 additions
and
96 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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils' | ||
import PluginWrapper from '@/components/Plugin/PluginWrapper' | ||
import { Wormhole } from 'portal-vue' | ||
|
||
const vue = createLocalVue() | ||
|
||
jest.mock('portal-vue', () => ({ | ||
Wormhole: { | ||
open: jest.fn(), | ||
close: jest.fn() | ||
} | ||
})) | ||
|
||
describe('PluginWrapper', () => { | ||
const mountComponent = config => { | ||
return mount(PluginWrapper, config) | ||
} | ||
|
||
describe('when there is a footer slot', () => { | ||
it('should open a Wormhole when mounted', done => { | ||
const spy = jest.spyOn(Wormhole, 'open') | ||
|
||
const wrapper = mountComponent({ | ||
slots: { | ||
footer: '<div></div>' | ||
} | ||
}) | ||
|
||
vue.nextTick(() => { | ||
expect(spy).toHaveBeenCalledWith({ | ||
to: 'plugin-footer', | ||
from: 'plugin-wrapper', | ||
passengers: wrapper.vm.footerSlot | ||
}) | ||
done() | ||
}) | ||
|
||
spy.mockRestore() | ||
}) | ||
|
||
it('should close a Wormhole when destroyed', done => { | ||
const spy = jest.spyOn(Wormhole, 'close') | ||
|
||
mountComponent({ | ||
slots: { | ||
footer: '<div></div>' | ||
} | ||
}).destroy() | ||
|
||
vue.nextTick(() => { | ||
expect(spy).toHaveBeenCalledWith({ | ||
to: 'plugin-footer', | ||
from: 'plugin-wrapper' | ||
}) | ||
done() | ||
}) | ||
|
||
spy.mockRestore() | ||
}) | ||
}) | ||
|
||
describe('when there is no footer slot', () => { | ||
it('should not open a Wormhole when mounted', done => { | ||
const spy = jest.spyOn(Wormhole, 'open') | ||
|
||
mountComponent() | ||
|
||
vue.nextTick(() => { | ||
expect(spy).not.toHaveBeenCalled() | ||
done() | ||
}) | ||
|
||
spy.mockRestore() | ||
}) | ||
|
||
it('should not close a Wormhole when destroyed', done => { | ||
const spy = jest.spyOn(Wormhole, 'close') | ||
|
||
mountComponent().destroy() | ||
|
||
vue.nextTick(() => { | ||
expect(spy).not.toHaveBeenCalled() | ||
done() | ||
}) | ||
|
||
spy.mockRestore() | ||
}) | ||
}) | ||
}) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.