Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit 01a0a89

Browse files
author
wanasit
committed
Rewrite the test into jest format
1 parent dcb32f5 commit 01a0a89

File tree

95 files changed

+12280
-13009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+12280
-13009
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ coverage/
77
# Misc
88
.Rhistory
99
.idea/
10-
10+
.DS_Store
11+
.vscode
12+
.settings
1113

test/de.test.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
var chrono = require('../src/chrono');
2+
test('Test - Random text', function() {
3+
4+
var text = "...Donnerstag, 15. Dezember 2011 Best Available Rate "
5+
var results = chrono.parse(text);
6+
expect(results.length).toBeGreaterThanOrEqual(1)
7+
expect(results[0].start.get('day')).toBe(15)
8+
expect(results[0].start.get('month')).toBe(12)
9+
expect(results[0].start.get('year')).toBe(2011)
10+
11+
12+
var text = "9:00 bis 17:00, Dienstag, 20. Mai 2013"
13+
var results = chrono.parse(text);
14+
expect(results.length).toBe(1)
15+
expect(results[0].start.get('hour')).toBe(9)
16+
expect(results[0].end.get('hour')).toBe(17)
17+
expect(results[0].end.get('meridiem')).toBe(1)
18+
expect(results[0].end.get('day')).toBe(20)
19+
expect(results[0].end.get('month')).toBe(5)
20+
expect(results[0].end.get('year')).toBe(2013)
21+
});
22+
23+
24+
test('Test - German support in default setting', function() {
25+
26+
// German's formal text should be handle by default casual and strict
27+
28+
var text = "9:00 bis 17:00, Dienstag, 20. Mai 2013";
29+
30+
var results = chrono.parse(text);
31+
expect(results.length).toBe(1);
32+
33+
var results = chrono.strict.parse(text);
34+
expect(results.length).toBe(1);
35+
36+
var results = chrono.de.parse(text);
37+
expect(results.length).toBe(1);
38+
39+
// German's casual text (e.g. "do" is abbreviation of "Donnerstag")should be skipped
40+
41+
var text = "Do";
42+
43+
var results = chrono.parse(text);
44+
expect(results.length).toBe(0);
45+
46+
var results = chrono.strict.parse(text);
47+
expect(results.length).toBe(0);
48+
49+
var results = chrono.de.parse(text);
50+
expect(results.length).toBe(1);
51+
});

0 commit comments

Comments
 (0)