Extract a TestLocalStore (#527)

Summary:
Test code should probably always use a checked, memory-backed local
storage implementation. This endpoint will help users not forget to
include the checks.

wchargin-branch: test-local-store
This commit is contained in:
William Chargin 2018-07-26 15:05:43 -07:00 committed by GitHub
parent 8655838b2c
commit e0c97fee9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -2,7 +2,7 @@
import React from "react";
import {shallow} from "enzyme";
import MemoryLocalStore from "../memoryLocalStore";
import TestLocalStore from "../memoryLocalStore";
import {pagerank} from "../../core/attribution/pagerank";
import {App} from "./App";
@ -96,20 +96,17 @@ function example() {
}
describe("app/credExplorer/App", () => {
function makeLocalStore() {
return new MemoryLocalStore();
}
it("renders with clean state", () => {
shallow(<App localStore={makeLocalStore()} />);
shallow(<App localStore={new TestLocalStore()} />);
});
it("renders with graph and adapters set", () => {
const app = shallow(<App localStore={makeLocalStore()} />);
const app = shallow(<App localStore={new TestLocalStore()} />);
const {graph, adapters} = example();
const data = {graph, adapters, pagerankResult: null};
app.setState({data});
});
it("renders with graph and adapters and pagerankResult", () => {
const app = shallow(<App localStore={makeLocalStore()} />);
const app = shallow(<App localStore={new TestLocalStore()} />);
const {graph, adapters, pagerankResult} = example();
const data = {graph, adapters, pagerankResult};
app.setState({data});

View File

@ -0,0 +1,6 @@
// @flow
import CheckedLocalStore from "./checkedLocalStore";
import MemoryLocalStore from "./memoryLocalStore";
export default new CheckedLocalStore(new MemoryLocalStore());