Skip to content

Commit

Permalink
Start of CommandTool specs, test perf boost
Browse files Browse the repository at this point in the history
  • Loading branch information
stewart committed Feb 27, 2015
1 parent 6d0ff38 commit ea2ab04
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Expand Up @@ -8,6 +8,7 @@

"TestUtils": true,
"source": true,
"before": true,
"beforeEach": true,
"afterEach": true,
"describe": true,
Expand Down
53 changes: 53 additions & 0 deletions spec/components/command-tool.spec.es
@@ -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: []
});
});
});
13 changes: 6 additions & 7 deletions spec/components/event-tool.spec.es
Expand Up @@ -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(() => {
Expand Down

0 comments on commit ea2ab04

Please sign in to comment.