|
| 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