Skip to content
Open
Changes from 1 commit
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
55 changes: 50 additions & 5 deletions src/ifElse.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
'use strict';

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

it('should ', () => {
test('calls condition callback', () => {
const condition = jest.fn(() => true);
const first = jest.fn();
const second = jest.fn();

});
ifElse(condition, first, second);

// write tests here
expect(condition).toHaveBeenCalled();
});

test('calls first callback when condition returns true', () => {
const condition = jest.fn(() => true);
const first = jest.fn();
const second = jest.fn();

ifElse(condition, first, second);

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

test('calls second callback when condition returns false', () => {
const condition = jest.fn(() => false);
const first = jest.fn();
const second = jest.fn();

ifElse(condition, first, second);

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

test('callbacks are called without arguments', () => {
const condition = jest.fn(() => true);
const first = jest.fn();
const second = jest.fn();

ifElse(condition, first, second);

expect(first).toHaveBeenCalledWith();
expect(condition).toHaveBeenCalledWith();
});

test('returns nothing', () => {
const condition = jest.fn(() => false);
const first = jest.fn();
const second = jest.fn();

const result = ifElse(condition, first, second);

expect(result).toBeUndefined();
});
Loading