Fixed tests

plugin_content_scripts
Laurent Cozic 2020-10-19 14:29:40 +01:00
parent 388a56c5dd
commit d927a238bb
2 changed files with 10 additions and 4 deletions

View File

@ -317,7 +317,7 @@ describe('services_KeymapService', () => {
],
[
{ command: 'showLocalSearch', accelerator: 'Ctrl+Alt+S' },
{ command: 'print', accelerator: 'Ctrl+G' /* Default of gotoAnything */ },
{ command: 'print', accelerator: 'Ctrl+P' /* Default of gotoAnything */ },
{ command: 'focusElementNoteTitle', accelerator: 'Ctrl+Alt+Shift+J' },
],
];

View File

@ -2,6 +2,9 @@ import PluginRunner from '../app/services/plugins/PluginRunner';
import PluginService from 'lib/services/plugins/PluginService';
import { ContentScriptType } from 'lib/services/plugins/api/types';
import MdToHtml from 'lib/joplin-renderer/MdToHtml';
import Setting from 'lib/models/Setting';
import shim from 'lib/shim';
import uuid from 'lib/uuid';
require('app-module-path').addPath(__dirname);
const { asyncTest, setupDatabaseAndSynchronizer, switchClient, expectThrow } = require('test-utils.js');
@ -152,11 +155,12 @@ describe('services_PluginService', function() {
}));
it('should register a Markdown-it plugin', asyncTest(async () => {
const contentScriptPath = `${testContentScriptDir}/markdownItPluginTest.js`;
const contentScriptPath = `${Setting.value('tempDir')}/markdownItPluginTest_${uuid.createNano()}.js`;
await shim.fsDriver().copy(`${testContentScriptDir}/markdownItPluginTest.js`, contentScriptPath);
const service = newPluginService();
const plugin = await service.loadPluginFromString('example', '/tmp', `
const plugin = await service.loadPluginFromString('example', Setting.value('tempDir'), `
/* joplin-manifest:
{
"manifest_version": 1,
@ -179,7 +183,7 @@ describe('services_PluginService', function() {
const contentScripts = plugin.contentScriptsByType(ContentScriptType.MarkdownItPlugin);
expect(contentScripts.length).toBe(1);
expect(contentScripts[0].path).toBe(contentScriptPath);
expect(!!contentScripts[0].path).toBe(true);
const contentScript = contentScripts[0];
@ -194,6 +198,8 @@ describe('services_PluginService', function() {
].join('\n'));
expect(result.html.includes('JUST TESTING: something')).toBe(true);
await shim.fsDriver().remove(contentScriptPath);
}));
});