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) + }) +})