(options?: PluginOptions)
| 16 | }; |
| 17 | |
| 18 | const loadPlugin = (options?: PluginOptions) => { |
| 19 | // Isolate vue and container |
| 20 | const localVue = createLocalVue(); |
| 21 | const container = document.createElement("div"); |
| 22 | let containerComp; |
| 23 | // Register the plugin and get the container component back |
| 24 | localVue.use(Toast, { |
| 25 | container, |
| 26 | onMounted: (containerComponent) => (containerComp = containerComponent), |
| 27 | ...options, |
| 28 | }); |
| 29 | const containerWrapper = createWrapper( |
| 30 | (containerComp as unknown) as CombinedVueInstance< |
| 31 | Record<never, unknown> & Vue, |
| 32 | unknown, |
| 33 | unknown, |
| 34 | unknown, |
| 35 | Record<never, unknown> |
| 36 | > |
| 37 | ); |
| 38 | |
| 39 | const positionContainers = { |
| 40 | topLeft: withGetToasts(containerWrapper.find(`.${POSITION.TOP_LEFT}`)), |
| 41 | topCenter: withGetToasts(containerWrapper.find(`.${POSITION.TOP_CENTER}`)), |
| 42 | topRight: withGetToasts(containerWrapper.find(`.${POSITION.TOP_RIGHT}`)), |
| 43 | bottomLeft: withGetToasts( |
| 44 | containerWrapper.find(`.${POSITION.BOTTOM_LEFT}`) |
| 45 | ), |
| 46 | bottomCenter: withGetToasts( |
| 47 | containerWrapper.find(`.${POSITION.BOTTOM_CENTER}`) |
| 48 | ), |
| 49 | bottomRight: withGetToasts( |
| 50 | containerWrapper.find(`.${POSITION.BOTTOM_RIGHT}`) |
| 51 | ), |
| 52 | }; |
| 53 | |
| 54 | return { localVue, containerWrapper, ...positionContainers }; |
| 55 | }; |
| 56 | |
| 57 | export { loadPlugin }; |
no test coverage detected
searching dependent graphs…