UNPKG

unroll

Version:

A helper tool to easily iterate through test data against a test method with verbose output about each iteration.

75 lines (66 loc) 1.75 kB
var chai = require('chai'); var unroll = require('../../index.js'); var expect = chai.expect; var jasmineReporters = require('jasmine-reporters'); jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({ verbosity: 3, color: true, showStack: true })); unroll.use(it); describe('[jasmine bdd] maximum of two numbers (without unroll)', function () { it('is performed correctly', function (done) { expect(Math.max(3, 5)).to.be.equal(5); expect(Math.max(7, 0)).to.be.equal(7); done(); }); }); describe('[jasmine bdd] maximum of two numbers (unrolled)', function () { unroll('maximum of #a and #b is #c', function (done, testArgs) { expect( Math.max(testArgs.a, testArgs.b) ).to.be.equal(testArgs.c); done(); }, [ ['a', 'b', 'c'], [3, 5, 5], [7, 0, 7] /* change last entry to [7, 0, 0] to see failure */ ] ); /* * The parameters in the title are out of sequence with the passed parameters. */ unroll('calculates the maximum of #b and #a', function (done, testArgs) { expect( Math.max(testArgs.a, testArgs.b) ).to.be.equal(testArgs.c); done(); }, [ ['a', 'b', 'c'], [3, 5, 5], [7, 0, 7] /* change last entry to [7, 0, 0] to see failure */ ] ); /* * The parameters in the title are out of sequence with the passed parameters. */ unroll('calculates the maximum of #b and #a (non-callback style)', function (testArgs) { expect( Math.max(testArgs.a, testArgs.b) ).to.be.equal(testArgs.c); }, [ ['a', 'b', 'c'], [3, 5, 5], [7, 0, 7] /* change last entry to [7, 0, 0] to see failure */ ] ); });