-
Notifications
You must be signed in to change notification settings - Fork 253
solution #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
solution #242
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,43 @@ | ||
| 'use strict'; | ||
|
|
||
| describe('ifElse', () => { | ||
| // const { ifElse } = require('./ifElse'); | ||
| const { ifElse } = require('./ifElse'); | ||
| let conditionTrue; | ||
| let conditionFalse; | ||
| let first; | ||
| let second; | ||
|
|
||
| it('should ', () => { | ||
| beforeEach(() => { | ||
| conditionTrue = jest.fn(() => true); | ||
| conditionFalse = jest.fn(() => false); | ||
| first = jest.fn(); | ||
| second = jest.fn(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| conditionTrue.mockRestore(); | ||
| conditionFalse.mockRestore(); | ||
| first.mockRestore(); | ||
| second.mockRestore(); | ||
| }); | ||
|
|
||
| it('should return noting', () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a small typo in the test description. It should probably be "nothing" instead of "noting". |
||
| expect(ifElse(conditionTrue, first, second)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('should pass first fuction if condition is true', () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a typo in the test description. It should be 'function' instead of 'fuction'. |
||
| ifElse(conditionTrue, first, second); | ||
|
|
||
| expect(conditionTrue).toHaveBeenCalledTimes(1); | ||
| expect(first).toHaveBeenCalledTimes(1); | ||
| expect(second).not.toHaveBeenCalledTimes; | ||
|
||
| }); | ||
|
|
||
| // write tests here | ||
| it('should pass first fuction if condition is false', () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test description is misleading and contains a typo. This test case verifies that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test description seems a bit misleading. While the test itself is correct, the description says it should pass the "first function", but it actually verifies that the |
||
| ifElse(conditionFalse, first, second); | ||
|
|
||
| expect(conditionFalse).toHaveBeenCalledTimes(1); | ||
| expect(first).not.toHaveBeenCalledTimes; | ||
|
||
| expect(second).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a small typo in the test description. It should be 'nothing' instead of 'noting'.