-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
56 lines (45 loc) · 1.57 KB
/
index.test.js
File metadata and controls
56 lines (45 loc) · 1.57 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const index = require("./index.js");
const today = new Date();
const todayDay = today.getDate();
const todayMonth = today.getMonth() + 1;
const todayYear = today.getFullYear();
test("parsing date: 1 jun", () => {
expect(index.parseDate("1 янв")).toBe("01/01/" + todayYear);
});
test("parsing date: 15 dec 12", () => {
expect(index.parseDate("15 дек 12")).toBe("15/12/2012");
});
test("parsing date: 1 jan", () => {
expect(index.parseDate("1 января")).toBe("01/01/" + todayYear);
});
test("parsing date: 20 february 2020", () => {
expect(index.parseDate("20 февраля 2020")).toBe("20/02/2020");
});
test("parsing date: 1 1", () => {
expect(index.parseDate("1 1")).toBe("01/01/" + todayYear);
});
test("parsing date: 3 2 20", () => {
expect(index.parseDate("3 2 20")).toBe("03/02/2020");
});
test("parsing date: 01 01 20", () => {
expect(index.parseDate("01 01 20")).toBe("01/01/2020");
});
test("isDateFuture future years", () => {
expect(index.isDateFuture(todayDay, todayMonth, todayYear + 1)).toBe(true);
});
test("isDateFuture future month", () => {
expect(index.isDateFuture(todayDay, todayMonth + 1, todayYear)).toBe(true);
});
test("isDateFuture future day", () => {
expect(index.isDateFuture(todayDay + 1, todayMonth, todayYear)).toBe(true);
});
test("isDateFuture future month and past month", () => {
expect(index.isDateFuture(todayDay, todayMonth + 1, todayYear - 1)).toBe(
false
);
});
test("isDateFuture future day and past year", () => {
expect(index.isDateFuture(todayDay + 1, todayMonth, todayYear - 1)).toBe(
false
);
});