From d905e05a19c236eff204e85eef17996da4d73fbf Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 23 Dec 2019 16:05:22 +0200 Subject: [PATCH] typescript(option): test: added tests for count Signed-off-by: prescientmoon --- .../option/src/helpers/bindAsync.test.ts | 1 - typescript/option/src/helpers/count.test.ts | 22 +++++++++++++++++++ typescript/option/test/constants.ts | 2 ++ typescript/option/tsconfig.json | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 typescript/option/src/helpers/count.test.ts create mode 100644 typescript/option/test/constants.ts diff --git a/typescript/option/src/helpers/bindAsync.test.ts b/typescript/option/src/helpers/bindAsync.test.ts index 2ec2bfe..8610cf6 100644 --- a/typescript/option/src/helpers/bindAsync.test.ts +++ b/typescript/option/src/helpers/bindAsync.test.ts @@ -1,6 +1,5 @@ import { expect } from 'chai' import { Some, None } from '../types' -import { constantly } from '@thi.ng/compose' import { bindAsync } from './bindAsync' describe('The bindAsync helper', () => { diff --git a/typescript/option/src/helpers/count.test.ts b/typescript/option/src/helpers/count.test.ts new file mode 100644 index 0000000..7450a03 --- /dev/null +++ b/typescript/option/src/helpers/count.test.ts @@ -0,0 +1,22 @@ +import { expect } from 'chai' +import { Some, None } from '../types' +import { count } from './count' +import { x } from '../../test/constants' + +describe('The count helper', () => { + it('should return 1 when given Some', () => { + // act + const result = count(Some(x)) + + // assert + expect(result).to.equal(1) + }) + + it('should return 0 when given None', () => { + // act + const result = count(None) + + // assert + expect(result).to.equal(0) + }) +}) diff --git a/typescript/option/test/constants.ts b/typescript/option/test/constants.ts new file mode 100644 index 0000000..329bc93 --- /dev/null +++ b/typescript/option/test/constants.ts @@ -0,0 +1,2 @@ +// general value to pass around +export const x = Symbol('x') diff --git a/typescript/option/tsconfig.json b/typescript/option/tsconfig.json index fe39ee0..46c5041 100644 --- a/typescript/option/tsconfig.json +++ b/typescript/option/tsconfig.json @@ -8,5 +8,5 @@ "downlevelIteration": true, "target": "es6" }, - "include": ["src", "sandbox"] + "include": ["src", "sandbox", "test"] }