validate-growi-plugin-directive.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import path from 'path';
  2. import { GrowiPluginType } from '@growi/core';
  3. import { validateTemplatePluginGrowiDirective } from './validate-growi-plugin-directive';
  4. describe('validateTemplatePluginGrowiDirective()', () => {
  5. it('returns a data object', async() => {
  6. // setup
  7. const projectDirRoot = path.resolve(__dirname, '../../../../../test/fixtures/example-package/template1');
  8. // when
  9. const data = validateTemplatePluginGrowiDirective(projectDirRoot);
  10. // then
  11. expect(data).not.toBeNull();
  12. expect(data.growiPlugin).not.toBeNull();
  13. expect(data.growiPlugin.types).toStrictEqual([GrowiPluginType.Template]);
  14. expect(data.growiPlugin.tylocalespes).not.toBeNull();
  15. });
  16. describe('should throw an GrowiPluginValidationError', () => {
  17. it("when the pkg does not have 'growiPlugin.locale' directive", () => {
  18. // setup
  19. const projectDirRoot = path.resolve(__dirname, '../../../../../test/fixtures/example-package/invalid-template1');
  20. // when
  21. const caller = () => { validateTemplatePluginGrowiDirective(projectDirRoot) };
  22. // then
  23. expect(caller).toThrow("Template plugin must have 'supportingLocales' and that must have one or more locales");
  24. });
  25. });
  26. });