Skip to content

Commit

Permalink
add mock
Browse files Browse the repository at this point in the history
  • Loading branch information
s77rt committed Dec 10, 2024
1 parent 540db5f commit 82eef52
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions mock/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MarkdownTextInput} from '../src';
import type {parseExpensiMark} from '../src';

global.jsi_setMarkdownRuntime = jest.fn();
global.jsi_registerMarkdownWorklet = jest.fn();
global.jsi_unregisterMarkdownWorklet = jest.fn();

const parseExpensiMarkMock: typeof parseExpensiMark = () => {
'worklet';

return [];
};

export {MarkdownTextInput, parseExpensiMarkMock as parseExpensiMark};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"files": [
"src",
"lib",
"mock",
"android",
"apple",
"cpp",
Expand Down
5 changes: 2 additions & 3 deletions src/MarkdownTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ function initializeLiveMarkdownIfNeeded() {
if (initialized) {
return;
}
if (!NativeLiveMarkdownModule) {
throw new Error('[react-native-live-markdown] NativeLiveMarkdownModule is not available');
if (NativeLiveMarkdownModule) {
NativeLiveMarkdownModule.install();
}
NativeLiveMarkdownModule.install();
if (!global.jsi_setMarkdownRuntime) {
throw new Error('[react-native-live-markdown] global.jsi_setMarkdownRuntime is not available');
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"verbatimModuleSyntax": true,
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*"],
"include": ["src/**/*", "mock/**/*"],
"exclude": ["**/node_modules/**/*", "**/lib/**/*", "example/src/**/*", "WebExample/**/*"]
}

0 comments on commit 82eef52

Please sign in to comment.