stitch-ui
Version:
43 lines (36 loc) • 1.28 kB
JavaScript
/* global it, describe, beforeAll, expect */
import { testSetup, noConsoleErrorsAllowed } from "../../testutil";
import * as homeActions from "../actions";
global.navigator = {
userAgent: "node.js"
};
describe("home page", () => {
noConsoleErrorsAllowed();
let store;
let groupId;
beforeAll(async () => {
const testHarness = await testSetup();
store = testHarness.store;
groupId = testHarness.groupId;
});
it("starts with an empty app list", async () => {
await store.dispatch(homeActions.loadApps(groupId));
expect(store.getState().home.apps).toHaveLength(0);
});
let newApp;
it("can create an app", async () => {
newApp = await store.dispatch(
homeActions.createApp(groupId, "my-test-app")
);
expect(newApp.name).toEqual("my-test-app");
await store.dispatch(homeActions.loadApps(groupId));
expect(store.getState().home.apps).toHaveLength(1);
expect(store.getState().home.apps[0]).toEqual(newApp);
});
it("can delete an app", async () => {
expect(store.getState().home.apps).toHaveLength(1);
await store.dispatch(homeActions.deleteApp(newApp.groupId, newApp._id));
await store.dispatch(homeActions.loadApps(groupId));
expect(store.getState().home.apps).toHaveLength(0);
});
});