Skip to content

Commit

Permalink
add tests for subtract, sum and title
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed May 10, 2016
1 parent a2e693e commit 4ddf80d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timelion",
"version": "5.0.0-0.1.306",
"version": "5.0.0-0.1.307",
"dependencies": {
"body-parser": "^1.12.0",
"boom": "^2.8.0",
Expand Down
21 changes: 21 additions & 0 deletions series_functions/__test__/subtract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const filename = require('path').basename(__filename);
const fn = require(`../${filename}`);

const _ = require('lodash');
const expect = require('chai').expect;
const invoke = require('./helpers/invoke_series_fn.js');

describe(filename, () => {

let seriesList;
beforeEach(() => {
seriesList = require('./fixtures/seriesList.js')();
});

it('it subtracts a number', () => {
return invoke(fn, [seriesList, 2]).then((r) => {
expect(_.map(r.output.list[1].data, 1)).to.eql([98, 48, 48, 18]);
});
});

});
21 changes: 21 additions & 0 deletions series_functions/__test__/sum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const filename = require('path').basename(__filename);
const fn = require(`../${filename}`);

const _ = require('lodash');
const expect = require('chai').expect;
const invoke = require('./helpers/invoke_series_fn.js');

describe(filename, () => {

let seriesList;
beforeEach(() => {
seriesList = require('./fixtures/seriesList.js')();
});

it('it adds a number', () => {
return invoke(fn, [seriesList, 2]).then((r) => {
expect(_.map(r.output.list[1].data, 1)).to.eql([102, 52, 52, 22]);
});
});

});
21 changes: 21 additions & 0 deletions series_functions/__test__/title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const filename = require('path').basename(__filename);
const fn = require(`../${filename}`);

const _ = require('lodash');
const expect = require('chai').expect;
const invoke = require('./helpers/invoke_series_fn.js');

describe(filename, () => {

let seriesList;
beforeEach(() => {
seriesList = require('./fixtures/seriesList.js')();
});

it('sets the title property', () => {
return invoke(fn, [seriesList, 'beer']).then((r) => {
_.each(r.output.list, (series) => expect(series._title).to.equal('beer'));
});
});

});

0 comments on commit 4ddf80d

Please sign in to comment.