with-config-and-bootstrap.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { LanguageCode } from '@vendure/common/lib/generated-types';
  2. import {
  3. ConfigModule,
  4. ConfigService,
  5. OnVendureBootstrap,
  6. OnVendureClose,
  7. VendurePlugin,
  8. } from '@vendure/core';
  9. @VendurePlugin({
  10. imports: [ConfigModule],
  11. configuration: (config) => {
  12. // tslint:disable-next-line:no-non-null-assertion
  13. config.defaultLanguageCode = LanguageCode.zh;
  14. return config;
  15. },
  16. })
  17. export class TestPluginWithConfigAndBootstrap implements OnVendureBootstrap, OnVendureClose {
  18. private static boostrapWasCalled: any;
  19. static setup(boostrapWasCalled: (arg: any) => void) {
  20. TestPluginWithConfigAndBootstrap.boostrapWasCalled = boostrapWasCalled;
  21. return TestPluginWithConfigAndBootstrap;
  22. }
  23. constructor(private configService: ConfigService) {}
  24. onVendureBootstrap() {
  25. TestPluginWithConfigAndBootstrap.boostrapWasCalled(this.configService);
  26. }
  27. onVendureClose() {
  28. TestPluginWithConfigAndBootstrap.boostrapWasCalled.mockClear();
  29. }
  30. }