Skip to content

Commit

Permalink
Add specs for history slider (#1053)
Browse files Browse the repository at this point in the history
* Add specs for history slider

* Remove flow annotation from history-spec.js to make travis happy

* Remove uneccessary imports in history-spec.js
  • Loading branch information
xanecs authored and lgeiger committed Oct 17, 2017
1 parent e3316a7 commit 65d34d1
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions spec/components/result-view/history-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use babel";

import React from "react";
import Enzyme, { shallow } from "enzyme";

import History from "../../../lib/components/result-view/history";

describe("History", () => {
it("should render and display the current output", () => {
const mockStore = {
index: 0,
outputs: [{}, {}]
};

const component = shallow(<History store={mockStore} />);
expect(component.type()).not.toBeNull();
expect(component.text()).toContain("1/2");
});

it("should change the index when the arrows are clicked", () => {
const mockStore = {
index: 0,
outputs: [{}, {}],
setIndex: v => {
mockStore.index = v;
},
incrementIndex: () => {
mockStore.index++;
},
decrementIndex: () => {
mockStore.index--;
}
};

const component = shallow(<History store={mockStore} />);
component.find(".icon-chevron-right").simulate("click");
expect(mockStore.index).toBe(1);
component.find(".icon-chevron-left").simulate("click");
expect(mockStore.index).toBe(0);
});
});

0 comments on commit 65d34d1

Please sign in to comment.