From e241784601eaf44cd7e118e97832e96619e81763 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Wed, 25 Dec 2019 15:01:44 +0200 Subject: [PATCH] typescript(option): test: wrote tests for flat Signed-off-by: prescientmoon --- typescript/option/src/helpers/flat.test.ts | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 typescript/option/src/helpers/flat.test.ts diff --git a/typescript/option/src/helpers/flat.test.ts b/typescript/option/src/helpers/flat.test.ts new file mode 100644 index 0000000..2f52ec2 --- /dev/null +++ b/typescript/option/src/helpers/flat.test.ts @@ -0,0 +1,25 @@ +import { expect } from 'chai' +import { flat } from './flat' +import { None, Some } from '../types' +import { someX } from '../../test/constants' + +describe('The flat helper', () => { + it('should return None when given None', () => { + // act + const result = flat(None) + + // assert + expect(result).to.equal(None) + }) + + it('should return the inner Some(x) when given Some(Some(x))', () => { + // arrange + const value = Some(someX) + + // act + const result = flat(value) + + // assert + expect(result).to.equal(someX) + }) +})