Skip to content

Commit

Permalink
Use function in lesson 17
Browse files Browse the repository at this point in the history
  • Loading branch information
kay-is committed Oct 6, 2018
1 parent d20a23d commit 2e45c48
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions 17-unit-testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
mocha.setup("bdd");

// a simple component. It would normally be imported from another file
var MyComponent = () => (
<div>
<span className="heading">Title</span>
</div>
);
function MyComponent() {
return <div><span className="heading">Title</span></div>;
}

// the first test, Jest and Mocha both using describe() and it()
describe("Component", () => {
it("should render", () => {
describe("Component", function() {
it("should render", function() {
// a new renderer is created and used to render the component
var renderer = new ReactShallowRenderer();
renderer.render(<MyComponent />);
Expand Down Expand Up @@ -67,13 +65,13 @@
// mocking a function to test callback behaviour
var mockCallback = jest.fn();

describe("Callback", () => {
it("should be called two times", () => {
describe("Callback", function() {
it("should be called two times", function() {
// a test function that calls a callback two times
var callCallback = c => {
function callCallback(c) {
c();
c();
};
}

callCallback(mockCallback);

Expand Down

0 comments on commit 2e45c48

Please sign in to comment.