Skip to content

Commit

Permalink
Improve test messages for exercise no. 3. Ref #4
Browse files Browse the repository at this point in the history
  • Loading branch information
voter101 committed Jul 6, 2015
1 parent 4cdc2b7 commit ea3e5b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions koans/es6/03-WhatsYourName.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var React = require("react");

// Let's get to the most important feature of React.js - Reactive State.
// Let's get to the most important feature of React.js - reactive state.
//
// Each React component has 2 important hashes:
// Each React component contains 2 important hashes:
// * Properties - we pass these values when we create component. They don't
// change over entire life of the component.
// * State - these values can change over entire life of the component.
Expand Down
15 changes: 7 additions & 8 deletions test/es6/03-WhatsYourName.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ describe("03 - What's Your Name?", () => {
var input = _.first(inputs);
var paragraph = _.first(paragraphs);

assert.equal(paragraphs.length, 1, "There should be only one paragraph on component");
assert.equal(inputs.length, 1, "There should be only one input on component");
assert.equal(paragraphs.length, 1, "There should be only one `p` element rendered by the component");
assert.equal(inputs.length, 1, "There should be only one `input` rendered by the component");

React.addons.TestUtils.Simulate.change(input, {target: { value: "XYZ" } });
assert.equal(nameInParagraphEqualsTo(paragraph, 'XYZ'), true, "After changing name in input, we should see the change in paragraph.");
assert.equal(nameInParagraphEqualsTo(paragraph, 'XYZ'), true, "After changing name in input, I should see the change in `p` element's content. In other words: `this.state.name` should change.");

React.addons.TestUtils.Simulate.change(input, {target: { value: "ZYX" } });
assert.equal(nameInParagraphEqualsTo(paragraph, 'ZYX'), true, "After changing name in input for the second time, we should see the change in paragraph.");
assert.equal(nameInParagraphEqualsTo(paragraph, 'ZYX'), true, "After changing name in input for the second time, we should see the change in `p` element. In other words: `this.state.name` should change.");
});
});

Expand All @@ -46,10 +46,9 @@ describe("03 - What's Your Name?", () => {
var paragraph = _.first(paragraphs);

React.addons.TestUtils.Simulate.change(input, {target: { value: "" } });
assert.equal(paragraph.props.children, "Hey there. Enter your name.", "If user didn't enter the name, show \"Hey there. Enter your name.\". See the hint in task's description. The code you need to write is almost the same.");

React.addons.TestUtils.Simulate.change(input, {target: { value: "XYZ" } });
assert.equal(nameInParagraphEqualsTo(paragraph, 'XYZ'), true, "When user input name, you should show greeting message in paragraph.");
assert.equal(paragraph.props.children, "Hey there. Enter your name.",
"If user didn't enter the name (`this.state.name` length is 0), show \"Hey there. Enter your name.\". See the hint in task's description."
);
});
});
});
Expand Down

0 comments on commit ea3e5b9

Please sign in to comment.