Permalink
Browse files

Start of CommandTool specs, test perf boost

  • Loading branch information...
stewart committed Feb 27, 2015
1 parent 6d0ff38 commit ea2ab04667586498a845439292806fa550dc3054
Showing with 60 additions and 7 deletions.
  1. +1 −0 .jshintrc
  2. +53 −0 spec/components/command-tool.spec.es
  3. +6 −7 spec/components/event-tool.spec.es
View
@@ -8,6 +8,7 @@
"TestUtils": true,
"source": true,
"before": true,
"beforeEach": true,
"afterEach": true,
"describe": true,
@@ -0,0 +1,53 @@
// jshint expr:true
"use strict";
const CommandTool = source("components/command-tool.es");
function render(props = {}) {
return TestUtils.renderIntoDocument(
<CommandTool {...props} />
);
}
function searchMany(component) {
return function(tag) {
return TestUtils.scryRenderedDOMComponentsWithTag(component, tag);
};
}
function searchOne(component) {
return function(tag) {
return TestUtils.findRenderedDOMComponentWithTag(component, tag);
};
}
describe("CommandTool", () => {
let component, findOne, findMany;
before(() => {
component = render({
commands: [ "commandA", "commandB", "commandC" ],
endpoint: "/api/endpoint"
});
findOne = searchOne(component);
findMany = searchMany(component);
})
beforeEach(() => {
component.state = component.getInitialState();
});
it("is a React component", () => {
expect(TestUtils.isElement(<CommandTool />)).to.be.eql(true);
});
it("has a default state", () => {
expect(component.state).to.be.eql({
command: "commandA",
params: [{ key: "", value: "", type: "string" }],
results: []
});
});
});
@@ -19,15 +19,14 @@ function searchComponentForTag(component) {
describe("EventTool", () => {
let component, search, MockEventSource;
before(() => {
component = render({ endpoint: "/api/endpoint" });
search = searchComponentForTag(component);
});
beforeEach(() => {
component.state = component.getInitialState();
global.EventSource = MockEventSource = spy();
component = render({
commands: [ "commandA", "commandB", "commandC" ],
endpoint: "/api/endpoint"
});
search = searchComponentForTag(component);
});
afterEach(() => {

0 comments on commit ea2ab04

Please sign in to comment.