Browse Source

[tests] Added spec

master
Muthu Kumar 6 years ago
parent
commit
280fa2c9ca
  1. 38
      spec/spec.js
  2. 11
      spec/support/jasmine.json

38
spec/spec.js

@ -0,0 +1,38 @@
'use strict';
const infiniteList = require('../index');
/* global describe it expect */
describe("InfiniteList", () => {
it("Should be 0", () => {
const infinite = infiniteList.create(0, x => x + 2);
expect(infinite.first().value).toBe(0);
})
it("Should be 22", () => {
const infinite = infiniteList.create(0, x => x + 2);
expect(infinite.get(11).value).toBe(22);
})
it("Should be [ 0, 2, 4, 6, 8 ]", () => {
const infinite = infiniteList.create(0, x => x + 2);
expect(infinite.take(5).map(x => x.value)).toEqual([ 0, 2, 4, 6, 8 ]);
})
it("Should be [ 16, 18, 20 ]", () => {
const infinite = infiniteList.create(0, x => x + 2);
expect(infinite.take(8, 10).map(x => x.value)).toEqual([ 16, 18, 20 ]);
})
it("Should be [ 0, 2, 4, 6, 8 ]", () => {
const infinite = infiniteList.create(0, x => x + 2);
const acc = [];
for(let i of infinite) {
if(i.index >= 5) break;
acc.push(i.value)
}
expect(acc).toEqual([ 0, 2, 4, 6, 8 ]);
})
})

11
spec/support/jasmine.json

@ -0,0 +1,11 @@
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": true
}
Loading…
Cancel
Save