Skip to content

Commit

Permalink
Basic Dev Mode tests (#70)
Browse files Browse the repository at this point in the history
* simple dev mode smoke test

* update README: provide a valid example schema
  • Loading branch information
cvara authored Feb 25, 2023
1 parent 6000f5a commit 7561a6e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const initialize = async () => {
properties: {
id: {
type: 'string',
maxLength: 100,
},
name: {
type: 'string',
Expand Down
35 changes: 35 additions & 0 deletions tests/devMode.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { setup, teardown, MyDatabase } from './helpers';

import { renderHook } from '@testing-library/react-hooks';
import { addRxPlugin } from 'rxdb';
import { RxDBDevModePlugin } from 'rxdb/plugins/dev-mode';
import Provider from '../src/Provider';
import { characters } from './mockData';
import useRxDB from '../src/useRxDB';

addRxPlugin(RxDBDevModePlugin);

describe('when RxDBDevModePlugin', () => {
let db: MyDatabase;

beforeAll(async done => {
db = await setup(characters, 'characters');
done();
});

afterAll(async done => {
await teardown(db);
done();
});

describe('useRxDB', () => {
it('should return the db instsance', () => {
const wrapper = ({ children }) => (
<Provider db={db}>{children}</Provider>
);
const { result } = renderHook(() => useRxDB(), { wrapper });
expect(result.current).toBe(db);
});
});
});
2 changes: 2 additions & 0 deletions tests/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ export const setupCollection = async (
properties: {
id: {
type: 'string',
maxLength: 100,
},
name: {
type: 'string',
maxLength: 100,
},
affiliation: {
type: 'string',
Expand Down

0 comments on commit 7561a6e

Please sign in to comment.