| 1 |
import Popper from '../../src/index.js'; |
| 2 |
|
| 3 |
/** |
| 4 |
* Create a factory function that produces auto-cleanup popper instances. |
| 5 |
* |
| 6 |
* This function must be called in the context of a `describe`, as it utilises |
| 7 |
* the `afterEach` API to schedule cleanup. |
| 8 |
*/ |
| 9 |
export default function makePopperFactory() { |
| 10 |
let poppers = []; |
| 11 |
|
| 12 |
afterEach(() => { |
| 13 |
poppers.forEach(instance => instance.destroy()); |
| 14 |
poppers = []; |
| 15 |
}); |
| 16 |
|
| 17 |
return function factory(...args) { |
| 18 |
const popper = new Popper(...args); |
| 19 |
poppers.push(popper); |
| 20 |
return popper; |
| 21 |
}; |
| 22 |
} |