Skip to content

Commit

Permalink
🔨 test file code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vinodnimbalkar committed Jan 29, 2021
1 parent 5573dea commit 40a28c6
Show file tree
Hide file tree
Showing 12 changed files with 6,976 additions and 9,465 deletions.
2 changes: 1 addition & 1 deletion dist/dinvishesh.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.modern.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.modern.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dinvishesh.umd.js.map

Large diffs are not rendered by default.

16,271 changes: 6,895 additions & 9,376 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dinvishesh",
"version": "1.0.1",
"version": "1.0.2",
"description": "A simple NPM Package which returns dinvishesh (On This Day in History). Get your daily dinvishesh and increase knowledge!",
"source": "src/index.js",
"main": "dist/dinvishesh.js",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const dinVisheshByCategory = category => {
/**
* Module exports
*/
module.exports = {
export {
dinVisheshToday,
dinVishesh,
dinVisheshAll,
Expand Down
150 changes: 71 additions & 79 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,84 @@
const data = require("../data/dinvishesh.json");
const index = require("../src/index.js");
import data from '../data/data.js';
import {
dinVisheshToday,
dinVishesh,
dinVisheshAll,
dinVisheshByCategory,
} from '../src/index.js';

const assert = require("chai").assert;
import chai from 'chai';
const { assert } = chai;

describe("dinVisheshToday", () => {
it(`does not return undefined for the current day`, () => {
assert.isDefined(index.dinVisheshToday());
});
describe('dinVisheshToday', () => {
it(`does not return undefined for the current day`, () => {
assert.isDefined(dinVisheshToday());
});
});

describe("dinVishesh", () => {
const categoryMonthDayTheories = [
["janm", "february", "29"],
["mrutyu", "april", "20"],
["ghatana", "september", "15"]
];

categoryMonthDayTheories.map(([category, month, day]) => {
it(`returns data for ${category}/${month}/${day}`, () => {
assert.equal(
index.dinVishesh(category, month, day),
data.category[category][month][day]
);
});
describe('dinVishesh', () => {
const categoryMonthDayTheories = [
['janm', 'february', '29'],
['mrutyu', 'april', '20'],
['ghatana', 'september', '15'],
];

categoryMonthDayTheories.map(([category, month, day]) => {
it(`returns data for ${category}/${month}/${day}`, () => {
assert.equal(
dinVishesh(category, month, day),
data.category[category][month][day]
);
});
const categoryMonthTheories = [
["janm", "february", undefined],
["mrutyu", "april", ""],
["ghatana", "september", ""]
];
categoryMonthTheories.map(([category, month, day]) => {
it(`returns data for ${category}/${month} without day`, () => {
assert.equal(
index.dinVishesh(category, month, day),
data.category[category][month]
);
});
});

const categoryMonthTheories = [
['janm', 'february', undefined],
['mrutyu', 'april', ''],
['ghatana', 'september', ''],
];

categoryMonthTheories.map(([category, month, day]) => {
it(`returns data for ${category}/${month} without day`, () => {
assert.equal(
dinVishesh(category, month, day),
data.category[category][month]
);
});

const categoryTheories = [
["janm", undefined, undefined],
["mrutyu", "", ""],
["ghatana", "", ""],
];

categoryTheories.map(([category, month, day]) => {
it(`returns data for ${category} without month or day`, () => {
assert.equal(
index.dinVishesh(category, month, day),
data.category[category]
);
});
});

const categoryTheories = [
['janm', undefined, undefined],
['mrutyu', '', ''],
['ghatana', '', ''],
];

categoryTheories.map(([category, month, day]) => {
it(`returns data for ${category} without month or day`, () => {
assert.equal(dinVishesh(category, month, day), data.category[category]);
});
});
});

describe("dinVisheshAll", () => {
it("returns the same data as in dinvishesh.json", () => {
assert.equal(index.dinVisheshAll(), data);
});
describe('dinVisheshAll', () => {
it('returns the same data as in dinvishesh.json', () => {
assert.equal(dinVisheshAll(), data);
});
});

describe("dinVisheshByCategory", () => {
const definedTheories = [
["janm"],
["mrutyu"],
["ghatana"]
];

definedTheories.map(([category]) => {
it(`returns data from dinvishesh.json for category ${category}`, () => {
assert.equal(
index.dinVisheshByCategory(category),
data.category[category]
);
});
describe('dinVisheshByCategory', () => {
const definedTheories = [['janm'], ['mrutyu'], ['ghatana']];

definedTheories.map(([category]) => {
it(`returns data from dinvishesh.json for category ${category}`, () => {
assert.equal(dinVisheshByCategory(category), data.category[category]);
});

const undefinedTheories = [
["foo"],
["bar"],
["baz"],
];

undefinedTheories.map(([category]) => {
it(`returns undefined for missing category ${category}`, () => {
assert.isUndefined(index.dinVisheshByCategory("foo"));
});
});

const undefinedTheories = [['foo'], ['bar'], ['baz']];

undefinedTheories.map(([category]) => {
it(`returns undefined for missing category ${category}`, () => {
assert.isUndefined(dinVisheshByCategory('foo'));
});
});
});
});

0 comments on commit 40a28c6

Please sign in to comment.