-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for history slider (#1053)
* 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
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |