|
@@ -2,19 +2,22 @@ import fs from 'fs';
|
|
|
import path from 'path';
|
|
import path from 'path';
|
|
|
|
|
|
|
|
import { PLUGIN_STORING_PATH } from '../../consts';
|
|
import { PLUGIN_STORING_PATH } from '../../consts';
|
|
|
|
|
+import { GrowiPlugin } from '../../models';
|
|
|
|
|
|
|
|
import { growiPluginService } from './growi-plugin';
|
|
import { growiPluginService } from './growi-plugin';
|
|
|
|
|
|
|
|
describe('Installing a GROWI template plugin', () => {
|
|
describe('Installing a GROWI template plugin', () => {
|
|
|
|
|
|
|
|
- it('should success', async() => {
|
|
|
|
|
|
|
+ it('install() should success', async() => {
|
|
|
// when
|
|
// when
|
|
|
const result = await growiPluginService.install({
|
|
const result = await growiPluginService.install({
|
|
|
url: 'https://github.com/weseek/growi-plugin-templates-for-office',
|
|
url: 'https://github.com/weseek/growi-plugin-templates-for-office',
|
|
|
});
|
|
});
|
|
|
|
|
+ const count = await GrowiPlugin.count({ 'meta.name': 'growi-plugin-templates-for-office' });
|
|
|
|
|
|
|
|
// expect
|
|
// expect
|
|
|
expect(result).toEqual('growi-plugin-templates-for-office');
|
|
expect(result).toEqual('growi-plugin-templates-for-office');
|
|
|
|
|
+ expect(count).toBe(1);
|
|
|
expect(fs.existsSync(path.join(
|
|
expect(fs.existsSync(path.join(
|
|
|
PLUGIN_STORING_PATH,
|
|
PLUGIN_STORING_PATH,
|
|
|
'weseek',
|
|
'weseek',
|
|
@@ -22,7 +25,11 @@ describe('Installing a GROWI template plugin', () => {
|
|
|
))).toBeTruthy();
|
|
))).toBeTruthy();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it('should success (re-install)', async() => {
|
|
|
|
|
|
|
+ it('install() should success (re-install)', async() => {
|
|
|
|
|
+ // confirm
|
|
|
|
|
+ const count1 = await GrowiPlugin.count({ 'meta.name': 'growi-plugin-templates-for-office' });
|
|
|
|
|
+ expect(count1).toBe(1);
|
|
|
|
|
+
|
|
|
// setup
|
|
// setup
|
|
|
const dummyFilePath = path.join(
|
|
const dummyFilePath = path.join(
|
|
|
PLUGIN_STORING_PATH,
|
|
PLUGIN_STORING_PATH,
|
|
@@ -37,10 +44,49 @@ describe('Installing a GROWI template plugin', () => {
|
|
|
const result = await growiPluginService.install({
|
|
const result = await growiPluginService.install({
|
|
|
url: 'https://github.com/weseek/growi-plugin-templates-for-office',
|
|
url: 'https://github.com/weseek/growi-plugin-templates-for-office',
|
|
|
});
|
|
});
|
|
|
|
|
+ const count2 = await GrowiPlugin.count({ 'meta.name': 'growi-plugin-templates-for-office' });
|
|
|
|
|
|
|
|
// expect
|
|
// expect
|
|
|
expect(result).toEqual('growi-plugin-templates-for-office');
|
|
expect(result).toEqual('growi-plugin-templates-for-office');
|
|
|
|
|
+ expect(count2).toBe(1);
|
|
|
expect(fs.existsSync(dummyFilePath)).toBeFalsy(); // the dummy file should be removed
|
|
expect(fs.existsSync(dummyFilePath)).toBeFalsy(); // the dummy file should be removed
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+describe('Installing a GROWI theme plugin', () => {
|
|
|
|
|
+
|
|
|
|
|
+ it('install() should success', async() => {
|
|
|
|
|
+ // when
|
|
|
|
|
+ const result = await growiPluginService.install({
|
|
|
|
|
+ url: 'https://github.com/weseek/growi-plugin-theme-welcome-to-fumiya-room',
|
|
|
|
|
+ });
|
|
|
|
|
+ const count = await GrowiPlugin.count({ 'meta.name': 'growi-plugin-theme-welcome-to-fumiya-room' });
|
|
|
|
|
+
|
|
|
|
|
+ // expect
|
|
|
|
|
+ expect(result).toEqual('growi-plugin-theme-welcome-to-fumiya-room');
|
|
|
|
|
+ expect(count).toBe(1);
|
|
|
|
|
+ expect(fs.existsSync(path.join(
|
|
|
|
|
+ PLUGIN_STORING_PATH,
|
|
|
|
|
+ 'weseek',
|
|
|
|
|
+ 'growi-plugin-theme-welcome-to-fumiya-room',
|
|
|
|
|
+ ))).toBeTruthy();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('findThemePlugin() should return data with metadata and manifest', async() => {
|
|
|
|
|
+ // confirm
|
|
|
|
|
+ const count = await GrowiPlugin.count({ 'meta.name': 'growi-plugin-theme-welcome-to-fumiya-room' });
|
|
|
|
|
+ expect(count).toBe(1);
|
|
|
|
|
+
|
|
|
|
|
+ // when
|
|
|
|
|
+ const results = await growiPluginService.findThemePlugin('welcome-to-fumiya-room');
|
|
|
|
|
+
|
|
|
|
|
+ // expect
|
|
|
|
|
+ // expect(results).not.toBeNull();
|
|
|
|
|
+ // assert(results != null);
|
|
|
|
|
+ // expect(results.growiPlugin).not.toBeNull();
|
|
|
|
|
+ // expect(results.themeMetadata).not.toBeNull();
|
|
|
|
|
+ // expect(results.themeHref).not.toBeNull();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+});
|