You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Chore: Mobile: Add NoteBodyViewer tests (#10747)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
/* eslint-disable jest/require-top-level-describe */
|
||||
|
||||
const { afterEachCleanUp, afterAllCleanUp } = require('@joplin/lib/testing/test-utils.js');
|
||||
const shim = require('@joplin/lib/shim').default;
|
||||
const { shimInit } = require('@joplin/lib/shim-init-node.js');
|
||||
const injectedJs = require('./utils/injectedJs.js').default;
|
||||
const { mkdir, rm } = require('fs-extra');
|
||||
const path = require('path');
|
||||
const sharp = require('sharp');
|
||||
const { tmpdir } = require('os');
|
||||
const uuid = require('@joplin/lib/uuid').default;
|
||||
const sqlite3 = require('sqlite3');
|
||||
@@ -19,7 +22,14 @@ window.setImmediate = setImmediate;
|
||||
shimInit({
|
||||
nodeSqlite: sqlite3,
|
||||
React,
|
||||
sharp,
|
||||
});
|
||||
shim.injectedJs = (name) => {
|
||||
if (!(name in injectedJs)) {
|
||||
throw new Error(`Cannot find injected JS with ID ${name}`);
|
||||
}
|
||||
return injectedJs[name];
|
||||
};
|
||||
|
||||
// This library has the following error when running within Jest:
|
||||
// Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
|
||||
@@ -40,17 +50,27 @@ jest.doMock('react-native-version-info', () => {
|
||||
});
|
||||
|
||||
// react-native-webview expects native iOS/Android code so needs to be mocked.
|
||||
jest.mock('react-native-webview', () => {
|
||||
const { View } = require('react-native');
|
||||
return {
|
||||
WebView: View,
|
||||
};
|
||||
jest.mock('./components/ExtendedWebView', () => {
|
||||
return require('./components/ExtendedWebView/index.jest.js');
|
||||
});
|
||||
|
||||
jest.mock('@react-native-clipboard/clipboard', () => {
|
||||
return { default: { getString: jest.fn(), setString: jest.fn() } };
|
||||
});
|
||||
|
||||
jest.mock('react-native-share', () => {
|
||||
return { default: { } };
|
||||
});
|
||||
|
||||
// Used by the renderer
|
||||
jest.doMock('react-native-vector-icons/Ionicons', () => {
|
||||
return {
|
||||
default: class extends require('react-native').View {
|
||||
static getImageSourceSync = () => ({ uri: '' });
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// react-native-fs's CachesDirectoryPath export doesn't work in a testing environment.
|
||||
// Use a temporary folder instead.
|
||||
const tempDirectoryPath = path.join(tmpdir(), `appmobile-test-${uuid.createNano()}`);
|
||||
|
||||
Reference in New Issue
Block a user