growi-plugin.integ.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { GrowiPluginType } from '@growi/core';
  2. import { GrowiPlugin } from './growi-plugin';
  3. describe('GrowiPlugin find methods', () => {
  4. beforeAll(async() => {
  5. await GrowiPlugin.insertMany([
  6. {
  7. isEnabled: false,
  8. installedPath: 'weseek/growi-plugin-unenabled1',
  9. organizationName: 'weseek',
  10. origin: {
  11. url: 'https://github.com/weseek/growi-plugin-unenabled1',
  12. },
  13. meta: {
  14. name: '@growi/growi-plugin-unenabled1',
  15. types: [GrowiPluginType.Script],
  16. },
  17. },
  18. {
  19. isEnabled: false,
  20. installedPath: 'weseek/growi-plugin-unenabled2',
  21. organizationName: 'weseek',
  22. origin: {
  23. url: 'https://github.com/weseek/growi-plugin-unenabled2',
  24. },
  25. meta: {
  26. name: '@growi/growi-plugin-unenabled2',
  27. types: [GrowiPluginType.Template],
  28. },
  29. },
  30. {
  31. isEnabled: true,
  32. installedPath: 'weseek/growi-plugin-example1',
  33. organizationName: 'weseek',
  34. origin: {
  35. url: 'https://github.com/weseek/growi-plugin-example1',
  36. },
  37. meta: {
  38. name: '@growi/growi-plugin-example1',
  39. types: [GrowiPluginType.Script],
  40. },
  41. },
  42. {
  43. isEnabled: true,
  44. installedPath: 'weseek/growi-plugin-example2',
  45. organizationName: 'weseek',
  46. origin: {
  47. url: 'https://github.com/weseek/growi-plugin-example2',
  48. },
  49. meta: {
  50. name: '@growi/growi-plugin-example2',
  51. types: [GrowiPluginType.Template],
  52. },
  53. },
  54. ]);
  55. });
  56. describe('.findEnabledPlugins', () => {
  57. it('shoud returns documents which isEnabled is true', async() => {
  58. // when
  59. const results = await GrowiPlugin.findEnabledPlugins();
  60. const pluginNames = results.map(p => p.meta.name);
  61. // then
  62. expect(results.length === 2).toBeTruthy();
  63. expect(pluginNames.includes('@growi/growi-plugin-example1')).toBeTruthy();
  64. expect(pluginNames.includes('@growi/growi-plugin-example2')).toBeTruthy();
  65. });
  66. });
  67. describe('.findEnabledPluginsByType', () => {
  68. it("shoud returns documents which type is 'template'", async() => {
  69. // when
  70. const results = await GrowiPlugin.findEnabledPluginsByType(GrowiPluginType.Template);
  71. const pluginNames = results.map(p => p.meta.name);
  72. // then
  73. expect(results.length === 1).toBeTruthy();
  74. expect(pluginNames.includes('@growi/growi-plugin-example2')).toBeTruthy();
  75. });
  76. });
  77. });