From 6f36c3d82692e628d1da729418601df3035315bf Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Thu, 26 Dec 2019 16:04:36 +0200 Subject: [PATCH] typescript(option): test: wrote tests for the 'withDefault' helper Signed-off-by: prescientmoon --- .../option/src/helpers/withDefault.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 typescript/option/src/helpers/withDefault.test.ts diff --git a/typescript/option/src/helpers/withDefault.test.ts b/typescript/option/src/helpers/withDefault.test.ts new file mode 100644 index 0000000..a661b2a --- /dev/null +++ b/typescript/option/src/helpers/withDefault.test.ts @@ -0,0 +1,22 @@ +import { expect } from 'chai' +import { withDefault } from './withDefault' +import { x } from '../../test/constants' +import { None, Some } from '../types' + +describe('The withDefault helper', () => { + it('should return the default when given None', () => { + // act + const result = withDefault(x, None) + + // assert + expect(result).to.equal(x) + }) + + it('should return x when given Some(x)', () => { + // act + const result = withDefault(0, Some(1)) + + // assert + expect(result).to.equal(1) + }) +})