-
Notifications
You must be signed in to change notification settings - Fork 59
/
index.js
31 lines (31 loc) · 2.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const moment = require("moment");
const customDateFormatting = require("../index");
var should = require('chai').should();
var nextOrPrevDateCustomFormat = customDateFormatting.getNextOrPrevDateCustomFormat, nextOrPrevMinuteDateCustomFormat = customDateFormatting.getNextOrPrevMinuteDateCustomFormat, nextOrPrevSecondDateCustomFormat = customDateFormatting.getNextOrPrevSecondDateCustomFormat, customSourceDateFormatToCustomNewDateFormat = customDateFormatting.customSourceDateFormatToCustomNewDateFormat, timeStampFromCurrentDateFormat = customDateFormatting.getTimeStampFromCurrentDateFormat;
describe('#nextOrPrevDateCustomFormat', function () {
it('converts input date to next date', function () {
nextOrPrevDateCustomFormat("YYYY-MM-DD", 1).should.equal(moment().add(1, "days").format("YYYY-MM-DD"));
});
});
describe('#nextOrPrevMinuteDateCustomFormat', function () {
it('converts input date, adding some minute', function () {
nextOrPrevMinuteDateCustomFormat("YYYY-MM-DD HH:mm", 1).should.equal(moment().add(1, "minutes").format("YYYY-MM-DD HH:mm"));
});
});
describe('#nextOrPrevSecondDateCustomFormat', function () {
it('converts input date, adding some second', function () {
nextOrPrevSecondDateCustomFormat("YYYY-MM-DD HH:mm:ss", 10).should.equal(moment().add(10, "seconds").format("YYYY-MM-DD HH:mm:ss"));
});
});
describe('#customSourceDateFormatToCustomNewDateFormat', function () {
it('Should convert input date to input format', function () {
customSourceDateFormatToCustomNewDateFormat(moment().format("YYYY-MM-DD HH:mm:ss"), "YYYY-MM-DD HH:mm:ss", "dddd DD MMM YYYY").should.equal(moment().format("dddd DD MMM YYYY"));
});
});
describe('#timeStampFromCurrentDateFormat', function () {
it('converts custom input date and its format to timestamp', function () {
timeStampFromCurrentDateFormat(moment().format("DD MMM YYYY"), "DD MMM YYYY").should.equal(Date.parse(moment().format("DD MMM YYYY")));
});
});