<TosUpdate/> test

This commit is contained in:
Rick Carlino 2017-12-11 09:30:17 -06:00
parent 3fb482db47
commit 5d631ce748
2 changed files with 20 additions and 6 deletions

View file

@ -11,15 +11,29 @@ jest.mock("../../i18n", () => {
});
import * as React from "react";
import { Wow } from "../index";
import { TosUpdate } from "../index";
import { shallow } from "enzyme";
describe("<Wow/>", () => {
describe("<TosUpdate/>", () => {
it("toggles server options", () => {
const x = shallow(<Wow />);
const wow = x.instance() as Wow;
const x = shallow(<TosUpdate />);
const wow = x.instance() as TosUpdate;
wow.toggleServerOpts();
expect(wow.state.hideServerSettings).toBeFalsy();
wow.toggleServerOpts();
expect(wow.state.hideServerSettings).toBeTruthy();
});
it("has a setter", () => {
type E = React.FormEvent<HTMLInputElement>;
const x = shallow(<TosUpdate />);
const wow = x.instance() as TosUpdate;
wow.setState = jest.fn();
const fn = wow.set("email");
fn({ currentTarget: { value: "foo@bar.com" } } as E);
expect(wow.setState).toHaveBeenCalledWith({ email: "foo@bar.com" });
});
it("submits a form", () => {
});
});

View file

@ -20,7 +20,7 @@ interface State {
serverPort: string;
}
export class Wow extends React.Component<Props, Partial<State>> {
export class TosUpdate extends React.Component<Props, Partial<State>> {
constructor() {
super();
this.submit = this.submit.bind(this);
@ -193,7 +193,7 @@ detectLanguage().then((config) => {
node.id = "root";
document.body.appendChild(node);
const reactElem = React.createElement(Wow, {});
const reactElem = React.createElement(TosUpdate, {});
const domElem = document.getElementById("root");
if (domElem) {