|
|
@@ -46,9 +46,23 @@ export class TestPluginWithAllLifecycleHooks
|
|
|
}
|
|
|
onVendureClose(): void | Promise<void> {
|
|
|
TestPluginWithAllLifecycleHooks.onCloseFn();
|
|
|
+ this.resetSpies();
|
|
|
}
|
|
|
onVendureWorkerClose(): void | Promise<void> {
|
|
|
TestPluginWithAllLifecycleHooks.onWorkerCloseFn();
|
|
|
+ this.resetSpies();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * This is required because on the first run, the Vendure server will be bootstrapped twice -
|
|
|
+ * once to populate the database and the second time forthe actual tests. Thus the call counts
|
|
|
+ * for the plugin lifecycles will be doubled. This method resets them after the initial
|
|
|
+ * (population) run.
|
|
|
+ */
|
|
|
+ private resetSpies() {
|
|
|
+ TestPluginWithAllLifecycleHooks.onConstructorFn.mockClear();
|
|
|
+ TestPluginWithAllLifecycleHooks.onBootstrapFn.mockClear();
|
|
|
+ TestPluginWithAllLifecycleHooks.onWorkerBootstrapFn.mockClear();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -165,7 +179,7 @@ export class TestPluginWithProvider {}
|
|
|
return config;
|
|
|
},
|
|
|
})
|
|
|
-export class TestPluginWithConfigAndBootstrap implements OnVendureBootstrap {
|
|
|
+export class TestPluginWithConfigAndBootstrap implements OnVendureBootstrap, OnVendureClose {
|
|
|
private static boostrapWasCalled: any;
|
|
|
static setup(boostrapWasCalled: (arg: any) => void) {
|
|
|
TestPluginWithConfigAndBootstrap.boostrapWasCalled = boostrapWasCalled;
|
|
|
@@ -176,4 +190,8 @@ export class TestPluginWithConfigAndBootstrap implements OnVendureBootstrap {
|
|
|
onVendureBootstrap() {
|
|
|
TestPluginWithConfigAndBootstrap.boostrapWasCalled(this.configService);
|
|
|
}
|
|
|
+
|
|
|
+ onVendureClose() {
|
|
|
+ TestPluginWithConfigAndBootstrap.boostrapWasCalled.mockClear();
|
|
|
+ }
|
|
|
}
|