index.test.ts 1.2 KB

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