Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/ifElse.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
'use strict';

describe('ifElse', () => {
// const { ifElse } = require('./ifElse');
const { ifElse } = require('./ifElse');

it('should ', () => {
it('should return first if condition is true', () => {
const condition = jest.fn(() => true);
const first = jest.fn();
const second = jest.fn();

ifElse(condition, first, second);

expect(condition).toHaveBeenCalled();
expect(first).toHaveBeenCalled();
expect(second).not.toHaveBeenCalled();
});

// write tests here
it('should return first if condition is true', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description for this test case appears to be copied from the one above. It should be updated to reflect that this test handles the scenario where the condition callback returns false.

const condition = jest.fn(() => false);
const first = jest.fn();
const second = jest.fn();

ifElse(condition, first, second);

expect(condition).toHaveBeenCalled();
expect(first).not.toHaveBeenCalled();
expect(second).toHaveBeenCalled();
});
});