Enable pouchdb-adapter-memory for usage in the tests #3

Merged
arran merged 2 commits from phloose/MyFin:tests into main 3 months ago
  1. 67
      __snapshots__/App.spec.ts.snap
  2. 12
      __tests__/App.spec.ts
  3. 13
      jest.setup.ts

67
__snapshots__/App.spec.ts.snap

@ -0,0 +1,67 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`App should render 1`] = `
<body>
<div>
<section
class="svelte-vlq5m3"
>
<nav
class="debug svelte-vlq5m3"
>
<button
class="danger svelte-vlq5m3"
>
Nuke
</button>
<button
class="svelte-vlq5m3"
>
Add Member
</button>
<button
class="svelte-vlq5m3"
>
Add Transaction
</button>
</nav>
<header
class="transaction-list svelte-vlq5m3"
>
<h2
class="svelte-vlq5m3"
>
Showing
<strong
class="svelte-vlq5m3"
>
0
</strong>
transactions
</h2>
<p
class="svelte-vlq5m3"
>
Viewing as:
<select
class="svelte-vlq5m3"
/>
</p>
</header>
<div
class="flexbox svelte-vlq5m3"
/>
</section>
</div>
</body>
`;

12
__tests__/App.spec.ts

@ -0,0 +1,12 @@
import { render, cleanup } from "@testing-library/svelte";
import App from "../src/App.svelte";
describe("App", () => {
afterEach(() => {
cleanup();
});
it("should render", () => {
const { container } = render(App);
expect(container).toMatchSnapshot();
});
});

13
jest.setup.ts

@ -4,3 +4,16 @@ import "@testing-library/jest-dom";
// not defined in a node environment in which the tests run. Needs further
// investigation how to handle RxDB properly.
global.fetch = jest.fn();
// We need to import the rxdb bundle which assigns the RxDB namespace to the global
// object which is the same like the window object in the tests. That way we can inject
// the in-memory adapter for use in the tests without changing the current
// implementation.
import "rxdb/dist/rxdb.browserify.js";
import * as inMemoryAdapter from "pouchdb-adapter-memory";
declare const global: any;
global.RxDB.addRxPlugin(inMemoryAdapter);
import rxdbSettings from "./src/abstractions/db/rxdb.settings";
rxdbSettings.adapter = "memory";
Loading…
Cancel
Save