1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Chore: Clean up tests

This commit is contained in:
Laurent Cozic 2022-11-05 12:17:56 +00:00
parent 85ab378ce6
commit 0ebaf3b0ce
3 changed files with 13 additions and 10 deletions

View File

@ -29,12 +29,15 @@ describe('pdfData', () => {
expect(pdf.pageCount).toBe(1);
});
test('Should throw error on invalid file', async () => {
const pdf = new PdfDocument(document);
await expect(async () => {
await pdf.loadDoc('');
}).rejects.toThrowError();
});
// Disable test because it throws warnings in console
// https://github.com/mozilla/pdf.js/issues/12443
// test('Should throw error on invalid file', async () => {
// const pdf = new PdfDocument(document);
// await expect(async () => {
// await pdf.loadDoc('');
// }).rejects.toThrowError();
// });
test('Should get correct page size', async () => {
const file = await loadFile(pdfFilePath1);

View File

@ -6,6 +6,7 @@ import { downloadPlugins, extractPlugins, localPluginsVersion } from './bundleDe
import { pathExists, readFile, remove } from 'fs-extra';
import Setting from '@joplin/lib/models/Setting';
import { createTempDir, supportDir } from '@joplin/lib/testing/test-utils';
import { rootDir } from './tool-utils';
const fetch = require('node-fetch');
@ -170,8 +171,6 @@ describe('bundleDefaultPlugins', function() {
.mockResolvedValueOnce({ text: () => Promise.resolve(NPM_Response2), ok: true })
.mockResolvedValueOnce({ buffer: () => Promise.resolve(tgzData), ok: true });
const tempDir = await createTempDir();
const downloadedPlugins = await downloadPlugins(testCase.localVersions, testDefaultPluginsInfo, manifests);
expect(downloadedPlugins[Object.keys(testDefaultPluginsInfo)[0]]).toBe(testCase.downloadedPlugin1);
@ -182,9 +181,10 @@ describe('bundleDefaultPlugins', function() {
testCase.calledWith.forEach((callValue, index) => expect(mockFetch).toHaveBeenNthCalledWith(index + 1, callValue));
jest.clearAllMocks();
await remove(tempDir);
}
await remove(`${rootDir}/packages/tools/joplin-plugin-backup-1.1.0.tgz`);
await remove(`${rootDir}/packages/tools/joplin-plugin-rich-markdown-0.9.0.tgz`);
});
it('should extract plugins files', async () => {

View File

@ -41,7 +41,7 @@ async function downloadFile(url: string, outputPath: string) {
export async function extractPlugins(currentDir: string, defaultPluginDir: string, downloadedPluginsNames: PluginIdAndName): Promise<void> {
for (const pluginId of Object.keys(downloadedPluginsNames)) {
await execCommand2(`tar xzf ${currentDir}/${downloadedPluginsNames[pluginId]}`);
await execCommand2(`tar xzf ${currentDir}/${downloadedPluginsNames[pluginId]}`, { quiet: true });
await move(`package/publish/${pluginId}.jpl`,`${defaultPluginDir}/${pluginId}/plugin.jpl`, { overwrite: true });
await move(`package/publish/${pluginId}.json`,`${defaultPluginDir}/${pluginId}/manifest.json`, { overwrite: true });
await remove(`${downloadedPluginsNames[pluginId]}`);