expo-sqlite-mock 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,3 +4,8 @@
4
4
  [![NPM Version](https://img.shields.io/npm/v/expo-sqlite-mock.svg)](https://www.npmjs.com/package/expo-sqlite-mock)
5
5
 
6
6
  Use expo-sqlite with jest.
7
+
8
+ ## Usage
9
+
10
+ 1. `npm install -D expo-sqlite-mock` or `bun add -D expo-sqlite-mock`
11
+ 2. Add `"setupFilesAfterEnv": ["expo-sqlite-mock/src/setup.ts"]` to your jest config (It's in `package.json` for default expo project).
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "expo-sqlite-mock",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "homepage": "https://github.com/zfben/expo-sqlite-mock",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/zfben/expo-sqlite-mock.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/zfben/expo-sqlite-mock/issues"
12
+ },
4
13
  "scripts": {
5
14
  "test": "jest"
6
15
  },
@@ -9,7 +18,8 @@
9
18
  "testRegex": "/*\\.test\\.tsx?$"
10
19
  },
11
20
  "files": [
12
- "src"
21
+ "src/ExpoSQLiteNext.ts",
22
+ "src/setup.ts"
13
23
  ],
14
24
  "peerDependencies": {
15
25
  "better-sqlite3": "*",
@@ -1,32 +0,0 @@
1
- import { mockedExpoSqliteNext } from '../ExpoSQLiteNext'
2
- import { Text } from 'react-native'
3
- import { SQLiteProvider, useSQLiteContext } from 'expo-sqlite'
4
- import { render, screen } from '@testing-library/react-native'
5
- import { useEffect, useState } from 'react'
6
-
7
- jest.mock(`${__dirname}/../../node_modules/expo-sqlite/build/ExpoSQLiteNext`, () => mockedExpoSqliteNext)
8
-
9
- it('SQLiteProvider', async () => {
10
- function Test() {
11
- const db = useSQLiteContext()
12
- const [version, setVersion] = useState('')
13
-
14
- useEffect(() => {
15
- setVersion(db.getFirstSync<{ 'sqlite_version()': string }>('SELECT sqlite_version()')['sqlite_version()'])
16
- }, [])
17
-
18
- return <Text>{version}</Text>
19
- }
20
-
21
- function App() {
22
- return (
23
- <SQLiteProvider databaseName='test.db'>
24
- <Test />
25
- </SQLiteProvider>
26
- )
27
- }
28
-
29
- render(<App />)
30
-
31
- expect(await screen.findByText(/[0-9]+.[0-9]+.[0-9]+/)).toBeTruthy()
32
- })