mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Tests: Fail test units when an uncaught exception is thrown inside asyncTest
This commit is contained in:
parent
cc7e2fc456
commit
f3e9668eb7
@ -2,8 +2,8 @@
|
||||
|
||||
require('app-module-path').addPath(__dirname);
|
||||
|
||||
const { extractExecutablePath, quotePath, unquotePath, friendlySafeFilename, toFileProtocolPath} = require('lib/path-utils.js');
|
||||
const { fileContentEqual, setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId, objectsEqual, checkThrowAsync } = require('test-utils.js');
|
||||
const { extractExecutablePath, quotePath, unquotePath, friendlySafeFilename, toFileProtocolPath } = require('lib/path-utils.js');
|
||||
const { asyncTest, fileContentEqual, setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId, objectsEqual, checkThrowAsync } = require('test-utils.js');
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||
@ -15,7 +15,7 @@ describe('pathUtils', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
it('should create friendly safe filename', async (done) => {
|
||||
it('should create friendly safe filename', asyncTest(async () => {
|
||||
const testCases = [
|
||||
['生活', '生活'],
|
||||
['not/good', 'not_good'],
|
||||
@ -34,11 +34,9 @@ describe('pathUtils', function() {
|
||||
|
||||
expect(!!friendlySafeFilename('')).toBe(true);
|
||||
expect(!!friendlySafeFilename('...')).toBe(true);
|
||||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should quote and unquote paths', async (done) => {
|
||||
it('should quote and unquote paths', asyncTest(async () => {
|
||||
const testCases = [
|
||||
['', ''],
|
||||
['/my/path', '/my/path'],
|
||||
@ -53,11 +51,9 @@ describe('pathUtils', function() {
|
||||
expect(quotePath(t[0])).toBe(t[1]);
|
||||
expect(unquotePath(quotePath(t[0]))).toBe(t[0]);
|
||||
}
|
||||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should extract executable path from command', async (done) => {
|
||||
it('should extract executable path from command', asyncTest(async () => {
|
||||
const testCases = [
|
||||
['', ''],
|
||||
['/my/cmd -some -args', '/my/cmd'],
|
||||
@ -71,11 +67,9 @@ describe('pathUtils', function() {
|
||||
const t = testCases[i];
|
||||
expect(extractExecutablePath(t[0])).toBe(t[1]);
|
||||
}
|
||||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should create correct fileURL syntax', async (done) => {
|
||||
it('should create correct fileURL syntax', asyncTest(async () => {
|
||||
const testCases_win32 = [
|
||||
['C:\\handle\\space test', 'file:///C:/handle/space+test'],
|
||||
['C:\\escapeplus\\+', 'file:///C:/escapeplus/%2B'],
|
||||
@ -95,8 +89,6 @@ describe('pathUtils', function() {
|
||||
const t = testCases_unixlike[i];
|
||||
expect(toFileProtocolPath(t[0], 'linux')).toBe(t[1]);
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -357,6 +357,7 @@ function asyncTest(callback) {
|
||||
await callback();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
expect('good').toBe('not good', 'Test has thrown an exception - see above error');
|
||||
} finally {
|
||||
done();
|
||||
}
|
||||
|
@ -6,10 +6,35 @@
|
||||
],
|
||||
"settings": {
|
||||
"files.exclude": {
|
||||
"**/node_modules/": true,
|
||||
"_mydocs/mdtest/": true,
|
||||
"_releases/": true,
|
||||
"_vieux/": true,
|
||||
"ElectronClient/app/fonts/": true,
|
||||
"*.sublime-workspace": true,
|
||||
"**/_mydocs/EnexSamples/*.enex": true,
|
||||
"**/*.base64": true,
|
||||
"**/*.bundle.js": true,
|
||||
"**/*.icns": true,
|
||||
"**/*.jar": true,
|
||||
"**/*.map": true,
|
||||
"**/*.min.css": true,
|
||||
"**/*.min.js": true,
|
||||
"**/*.po": true,
|
||||
"**/*.po~": true,
|
||||
"**/*.pot": true,
|
||||
"**/CliClient/app/lib": true,
|
||||
"**/CliClient/app/src": true,
|
||||
"**/docs/*.html": true,
|
||||
"**/docs/*.svg": true,
|
||||
"**/ElectronClient/app/css/font-awesome.min.css": true,
|
||||
"**/ElectronClient/app/gui/note-viewer/highlight/*.pack.js": true,
|
||||
"**/locales/*.json": true,
|
||||
"**/log.txt": true,
|
||||
"**/node_modules/": true,
|
||||
"**/package-lock.json": true,
|
||||
"**/ReactNativeClient/lib/mime-utils.js": true,
|
||||
"**/ReactNativeClient/locales/*": true,
|
||||
"**/src/log.txt": true,
|
||||
"**/yarn.lock": true,
|
||||
"CliClient/app/lib/": true,
|
||||
"CliClient/app/src/": true,
|
||||
"CliClient/build/": true,
|
||||
@ -20,50 +45,28 @@
|
||||
"CliClient/tests/fuzzing/": true,
|
||||
"CliClient/tests/src/": true,
|
||||
"CliClient/tests/sync/": true,
|
||||
"ElectronClient/dist/": true,
|
||||
"ElectronClient/build/": true,
|
||||
"Clipper/joplin-webclipper/dist/": true,
|
||||
"Clipper/joplin-webclipper/popup/build/": true,
|
||||
"ElectronClient/app/dist/": true,
|
||||
"ElectronClient/app/fonts/": true,
|
||||
"ElectronClient/app/gui/note-viewer/highlight/styles/": true,
|
||||
"ElectronClient/app/lib/": true,
|
||||
"ElectronClient/app/locale/": true,
|
||||
"ElectronClient/build/": true,
|
||||
"ElectronClient/dist/": true,
|
||||
"node_modules/": true,
|
||||
"ReactNativeClient/android/.gradle/": true,
|
||||
"ReactNativeClient/android/.idea/": true,
|
||||
"ReactNativeClient/android/app/build/": true,
|
||||
"ReactNativeClient/android/build/": true,
|
||||
"ReactNativeClient/android/local.properties/": true,
|
||||
"ReactNativeClient/node_modules/": true,
|
||||
"ElectronClient/app/gui/note-viewer/highlight/styles/": true,
|
||||
"tests/logs/": true,
|
||||
"ReactNativeClient/ios/build/": true,
|
||||
"ElectronClient/app/dist/": true,
|
||||
"_releases/": true,
|
||||
"ReactNativeClient/lib/csstojs/": true,
|
||||
"Clipper/joplin-webclipper/popup/build/": true,
|
||||
"Clipper/joplin-webclipper/dist/": true,
|
||||
"ReactNativeClient/lib/rnInjectedJs/": true,
|
||||
"**/*.jar": true,
|
||||
"**/*.map": true,
|
||||
"**/*.po": true,
|
||||
"**/*.po~": true,
|
||||
"**/*.pot": true,
|
||||
"**/CliClient/app/lib": true,
|
||||
"**/CliClient/app/src": true,
|
||||
"**/locales/*.json": true,
|
||||
"**/log.txt": true,
|
||||
"**/package-lock.json": true,
|
||||
"**/ReactNativeClient/locales/*": true,
|
||||
"**/src/log.txt": true,
|
||||
"**/ElectronClient/app/gui/note-viewer/highlight/*.pack.js": true,
|
||||
"**/ElectronClient/app/css/font-awesome.min.css": true,
|
||||
"**/docs/*.html": true,
|
||||
"**/docs/*.svg": true,
|
||||
"**/ReactNativeClient/lib/mime-utils.js": true,
|
||||
"**/_mydocs/EnexSamples/*.enex": true,
|
||||
"**/*.min.css": true,
|
||||
"**/*.min.js": true,
|
||||
"**/*.bundle.js": true,
|
||||
"**/yarn.lock": true,
|
||||
"**/*.icns": true,
|
||||
"**/*.base64": true,
|
||||
"ReactNativeClient/node_modules/": true,
|
||||
"Server/db*.sqlite/": true,
|
||||
"Server/dist/": true,
|
||||
"tests/logs/": true,
|
||||
}
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user