Skip to content

Commit bd22e42

Browse files
test: set up and create tests (#186)
1 parent 2e397d5 commit bd22e42

44 files changed

Lines changed: 7183 additions & 203 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: "20"
18+
cache: "yarn"
19+
20+
- name: Install dependencies
21+
run: yarn install --frozen-lockfile
22+
23+
- name: Run tests
24+
run: yarn test --forceExit --ci

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ assets/models/**/*.json
4747

4848

4949
key_local_mind
50-
android/local.properties
50+
android/local.properties
51+
52+
53+
coverage/

__mocks__/@gorhom/bottom-sheet.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { View } from 'react-native';
3+
4+
export const BottomSheetModal = React.forwardRef((_props: any, _ref: any) => null);
5+
export const BottomSheetView = ({ children, style }: any) => (
6+
<View style={style}>{children}</View>
7+
);
8+
export const BottomSheetBackdrop = () => null;
9+
export const BottomSheetModalProvider = ({ children }: any) => <>{children}</>;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const Clipboard = {
2+
setString: jest.fn(),
3+
getString: jest.fn(() => Promise.resolve('')),
4+
};
5+
6+
export default Clipboard;

__mocks__/async-storage.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const store: Record<string, string> = {};
2+
3+
const AsyncStorage = {
4+
getItem: jest.fn((key: string) => Promise.resolve(store[key] ?? null)),
5+
setItem: jest.fn((key: string, value: string) => {
6+
store[key] = value;
7+
return Promise.resolve();
8+
}),
9+
removeItem: jest.fn((key: string) => {
10+
delete store[key];
11+
return Promise.resolve();
12+
}),
13+
clear: jest.fn(() => {
14+
Object.keys(store).forEach((k) => delete store[k]);
15+
return Promise.resolve();
16+
}),
17+
getAllKeys: jest.fn(() => Promise.resolve(Object.keys(store))),
18+
multiGet: jest.fn((keys: string[]) =>
19+
Promise.resolve(keys.map((k) => [k, store[k] ?? null]))
20+
),
21+
};
22+
23+
export default AsyncStorage;

__mocks__/expo-file-system.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const File = jest.fn().mockImplementation(() => ({
2+
text: jest.fn(),
3+
}));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const AudioManager = {
2+
requestRecordingPermissions: jest.fn(() => Promise.resolve('Granted')),
3+
setAudioSessionOptions: jest.fn(),
4+
setAudioSessionActivity: jest.fn(() => Promise.resolve()),
5+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const DeviceInfo = {
2+
getTotalMemorySync: jest.fn(() => 8 * 1024 * 1024 * 1024), // 8 GB default
3+
getUsedMemory: jest.fn(() => Promise.resolve(0)),
4+
};
5+
6+
export default DeviceInfo;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const makeModelConstants = (name: string) => ({
2+
modelSource: `https://huggingface.co/mock/${name}/model.pte`,
3+
tokenizerSource: `https://huggingface.co/mock/${name}/tokenizer.json`,
4+
tokenizerConfigSource: `https://huggingface.co/mock/${name}/tokenizer_config.json`,
5+
});
6+
7+
export const QWEN3_0_6B_QUANTIZED = makeModelConstants('qwen3-0.6b-quantized');
8+
export const QWEN3_0_6B = makeModelConstants('qwen3-0.6b');
9+
export const QWEN3_1_7B = makeModelConstants('qwen3-1.7b');
10+
export const QWEN3_1_7B_QUANTIZED = makeModelConstants('qwen3-1.7b-quantized');
11+
export const QWEN3_4B = makeModelConstants('qwen3-4b');
12+
export const QWEN3_4B_QUANTIZED = makeModelConstants('qwen3-4b-quantized');
13+
export const LLAMA3_2_1B = makeModelConstants('llama3.2-1b');
14+
export const LLAMA3_2_1B_QLORA = makeModelConstants('llama3.2-1b-qlora');
15+
export const LLAMA3_2_1B_SPINQUANT = makeModelConstants('llama3.2-1b-spinquant');
16+
export const LLAMA3_2_3B = makeModelConstants('llama3.2-3b');
17+
export const LLAMA3_2_3B_QLORA = makeModelConstants('llama3.2-3b-qlora');
18+
export const LLAMA3_2_3B_SPINQUANT = makeModelConstants('llama3.2-3b-spinquant');
19+
export const HAMMER2_1_0_5B = makeModelConstants('hammer2.1-0.5b');
20+
export const HAMMER2_1_0_5B_QUANTIZED = makeModelConstants('hammer2.1-0.5b-quantized');
21+
export const HAMMER2_1_1_5B = makeModelConstants('hammer2.1-1.5b');
22+
export const HAMMER2_1_1_5B_QUANTIZED = makeModelConstants('hammer2.1-1.5b-quantized');
23+
export const HAMMER2_1_3B = makeModelConstants('hammer2.1-3b');
24+
export const HAMMER2_1_3B_QUANTIZED = makeModelConstants('hammer2.1-3b-quantized');
25+
export const QWEN2_5_0_5B = makeModelConstants('qwen2.5-0.5b');
26+
export const QWEN2_5_0_5B_QUANTIZED = makeModelConstants('qwen2.5-0.5b-quantized');
27+
export const QWEN2_5_1_5B = makeModelConstants('qwen2.5-1.5b');
28+
export const QWEN2_5_1_5B_QUANTIZED = makeModelConstants('qwen2.5-1.5b-quantized');
29+
export const QWEN2_5_3B = makeModelConstants('qwen2.5-3b');
30+
export const QWEN2_5_3B_QUANTIZED = makeModelConstants('qwen2.5-3b-quantized');
31+
export const PHI_4_MINI_4B = makeModelConstants('phi4-mini-4b');
32+
export const PHI_4_MINI_4B_QUANTIZED = makeModelConstants('phi4-mini-4b-quantized');
33+
export const LFM2_5_1_2B_INSTRUCT = makeModelConstants('lfm2.5-1.2b-instruct');
34+
export const LFM2_5_1_2B_INSTRUCT_QUANTIZED = makeModelConstants('lfm2.5-1.2b-instruct-quantized');
35+
export const WHISPER_TINY_EN = 'whisper-tiny-en';
36+
37+
export const LLMModule = {
38+
fromCustomModel: jest.fn(),
39+
};
40+
41+
export const SpeechToTextModule = {
42+
fromModelName: jest.fn(),
43+
};
44+
45+
export const TextEmbeddingsModule = {
46+
fromCustomModel: jest.fn(),
47+
};
48+
49+
export const ResourceFetcher = {
50+
fetch: jest.fn(),
51+
};

__mocks__/react-native-fs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const exists = jest.fn();
2+
export const unlink = jest.fn();
3+
export const copyFileAssets = jest.fn();

0 commit comments

Comments
 (0)