index.test.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import path from 'node:path';
  2. import {
  3. scanAllTemplates,
  4. validateAllTemplateLocales,
  5. validateTemplatePluginGrowiDirective,
  6. } from '@growi/pluginkit/dist/v4/server';
  7. const projectDirRoot = path.resolve(__dirname, '../');
  8. it('Validation for package.json should be passed', () => {
  9. // when
  10. const caller = () => validateTemplatePluginGrowiDirective(projectDirRoot);
  11. // then
  12. expect(caller).not.toThrow();
  13. });
  14. it('Validation for package.json should be return data', () => {
  15. // when
  16. const data = validateTemplatePluginGrowiDirective(projectDirRoot);
  17. // then
  18. expect(data).not.toBeNull();
  19. });
  20. it('Scanning the templates ends up with no errors', async () => {
  21. // when
  22. const results = await scanAllTemplates(projectDirRoot);
  23. // then
  24. expect(results).not.toBeNull();
  25. });
  26. it('Scanning the templates ends up with no errors with opts.data', async () => {
  27. // setup
  28. const data = validateTemplatePluginGrowiDirective(projectDirRoot);
  29. // when
  30. const results = await scanAllTemplates(projectDirRoot, { data });
  31. // then
  32. expect(results).not.toBeNull();
  33. });
  34. it('Validation templates returns true', () => {
  35. // when
  36. const result = validateAllTemplateLocales(projectDirRoot);
  37. // then
  38. expect(result).toBeTruthy();
  39. });