0.1.7 • Published 7 years ago

given-when-then-js v0.1.7

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

given-when-then-js

basic given when then test helper Javascript

install

npm i given-when-then-js

npm package link

how to use

var given = require('given-when-then-js');
var expect = require('chai').expect;

//alternativley with ES6 via transpilers
//import given from 'given-when-then-js';
//import { expect } from 'chai';

it('runs in the most basic form', () => {
	given(1)
		.when(value => 2)
		.then(value => value == 2);
});

it('should do a basic flow', () => {
	var givenValue = 1;
	var whenValue = 2;

	given(givenValue, "given a basic value")
		.when(value => {
			expect(value).to.equal(givenValue);
			/*perform action and return result*/
			return whenValue;
		}, "given value should be passed to when")
		.then(value => {
			/*check if the result matches the expected result*/
			expect(value).to.equal(whenValue);
		}, "when value should be passed to then");
});

see also

Java 8 version: given-when-then

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago