From 2e45c48de9aac57c4e5af8f668b83082844cfb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay=20Pl=C3=B6=C3=9Fer?= Date: Sat, 6 Oct 2018 16:46:16 +0200 Subject: [PATCH] Use function in lesson 17 --- 17-unit-testing.html | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/17-unit-testing.html b/17-unit-testing.html index d92e7d4..7aadbb4 100644 --- a/17-unit-testing.html +++ b/17-unit-testing.html @@ -30,15 +30,13 @@ mocha.setup("bdd"); // a simple component. It would normally be imported from another file -var MyComponent = () => ( -
- Title -
-); +function MyComponent() { + return
Title
; +} // 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(); @@ -67,13 +65,13 @@ var jest = window["jest-mock"]; // 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);