Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active June 27, 2018 04:00
Show Gist options
  • Select an option

  • Save cartant/d519d7660d962d9e3f24f62ffe4c8e98 to your computer and use it in GitHub Desktop.

Select an option

Save cartant/d519d7660d962d9e3f24f62ffe4c8e98 to your computer and use it in GitHub Desktop.
import { mount } from "enzyme";
import * as React from "react";
import { fakeSchedulers } from "rxjs-marbles/jest";
import { SomeComponent } from "./SomeComponent";
describe("SomeComponent", () => {
beforeEach(() => jest.useFakeTimers());
it("should indicate when searching", fakeSchedulers(advance => {
const wrapper = mount(<SomeComponent />);
expect(wrapper.find('.searching')).toHaveLength(0);
wrapper.find("input").simulate("change", { target: { value: "foo" } });
advance(400);
wrapper.update();
expect(wrapper.find('.searching')).toHaveLength(1);
expect(wrapper.find(".searching").html()).toMatch(/foo/);
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment