0.0.11 • Published 4 years ago

ts-test-functions v0.0.11

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Library to test functions in Typescript (inspired by Sinon)

Installation

npm install ts-test-functions

Usage

Typescript

import observer from 'ts-test-functions'


describe("observer class", () => {
	let obs1:observer;
	let f: Function;
	beforeEach(() => {
		obs1 = new observer();
		f = obs1.fake(42);
	});
	describe("fake", () => {
		it("should return a callable", () => {
			assert(f instanceof Function);
		});
		it("callable should return specified value", () => {
			assert(f() == 42);
		});
	});
	describe("callcount", () => {
		it("should return the number of calls", () => {
			assert(obs1.callcount() == 0);
			f();
			f();
			assert(obs1.callcount() == 2);
		});
	});
	describe("calledoncewith", () => {
		it("should return true if called once with specified arguments", () => {
			f(1, 2, 3);
			assert(obs1.calledoncewith(1, 2, 3));
		});
	});
	describe("call", () => {
		it("should return number of calls", () => {
			f(1);
			assert.deepEqual(obs1.call(0), [1]);
		});
	});
});
0.0.10

4 years ago

0.0.11

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago