moment-feiertage
Advanced tools
Comparing version 1.1.1 to 1.1.3
@@ -143,2 +143,17 @@ (function (root, factory) { | ||
if (year > 2018) { | ||
holidays['Internationaler Frauentag'] = { | ||
'date': moment(year + '-03-08'), | ||
'state': ['BE'], | ||
}; | ||
} | ||
// one time only holiday in Berlin | ||
if (year == 2020) { | ||
holidays['75. Jahrestag der Befreiung vom Nationalsozialismus und der Beendigung des zweiten Weltkrieges in Europa'] = { | ||
'date': moment(year + '-05-08'), | ||
'state': ['BE'], | ||
}; | ||
} | ||
for (var holiday in holidays) { | ||
@@ -207,2 +222,2 @@ if (momentObj.isSame(holidays[holiday].date, 'day')) { | ||
return moment; | ||
})); | ||
})); |
{ | ||
"name": "moment-feiertage", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"description": "Moment.js Plugin for german holidays; check if a given Date is a german holiday", | ||
@@ -14,2 +14,5 @@ "main": "moment-feiertage.js", | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bugs": { | ||
@@ -16,0 +19,0 @@ "url": "https://github.com/DaniSchenk/moment-feiertage/issues" |
@@ -0,0 +0,0 @@ # moment-feiertage |
66
test.js
@@ -8,5 +8,7 @@ const assert = require('assert'); | ||
const allStates = ['BW', 'BY', 'BE', 'BB', 'HB', 'HH', 'HE', 'MV', 'NI', 'NW', 'RP', 'SL', 'SN', 'ST', 'SH', 'TH']; | ||
// test some non-holiday dates | ||
it('should return false', () => { | ||
it('test non holiday dates', () => { | ||
// 1.0.0 | ||
assert.equal(false, moment('2017-01-03').isHoliday()); | ||
// 1.1.0 | ||
assert.deepEqual({ | ||
@@ -19,4 +21,7 @@ allStates: false, | ||
// test each single state | ||
for(const s of allStates) { | ||
// 1.0.0 | ||
assert.equal(false, moment('2017-01-03').isHoliday(s)); | ||
// 1.1.0 | ||
assert.deepEqual({ | ||
@@ -30,5 +35,7 @@ allStates: false, | ||
}); | ||
// test Christmas | ||
it('should return Christmas', () => { | ||
it('test 1. Weihnachtsfeiertag', () => { | ||
// 1.0.0 | ||
assert.equal('1. Weihnachtsfeiertag', moment('2019-12-25').isHoliday()); | ||
// 1.1.0 | ||
assert.deepEqual({ | ||
@@ -42,3 +49,5 @@ allStates: true, | ||
for(const s of allStates) { | ||
// 1.0.0 | ||
assert.equal('1. Weihnachtsfeiertag', moment('2019-12-25').isHoliday(s)); | ||
// 1.1.0 | ||
assert.deepEqual({ | ||
@@ -53,17 +62,46 @@ allStates: true, | ||
// test Christmas | ||
it('should return correct Object', () => { | ||
it('test Reformationstag', () => { | ||
// before 2017 | ||
const before2017 = ['BB', 'MV', 'SN', 'ST', 'TH']; | ||
for(const s of allStates) { | ||
let actual = false; | ||
if(before2017.includes(s)) { | ||
actual = 'Reformationstag'; | ||
} | ||
// 1.0.0 | ||
assert.equal(actual, moment('2016-10-31').isHoliday(s)); | ||
} | ||
// 1.1.0 | ||
assert.deepEqual({ | ||
allStates: false, | ||
holidayName: 'Allerheiligen', | ||
holidayStates: [ 'BW', 'BY', 'NW', 'RP', 'SL' ], | ||
holidayName: 'Reformationstag', | ||
holidayStates: before2017, | ||
testedStates: allStates | ||
}, moment('2018-11-01').isHoliday([])); | ||
}, moment('2016-10-31').isHoliday([])); | ||
// 2017 | ||
assert.deepEqual({ | ||
allStates: true, | ||
holidayName: 'Reformationstag', | ||
holidayStates: allStates, | ||
testedStates: allStates | ||
}, moment('2017-10-31').isHoliday([])); | ||
// after 2017 | ||
const after2017 = ['BB', 'HB', 'HH', 'MV', 'NI', 'SN', 'ST', 'SH', 'TH']; | ||
for(const s of allStates) { | ||
let actual = false; | ||
if(after2017.includes(s)) { | ||
actual = 'Reformationstag'; | ||
} | ||
// 1.0.0 | ||
assert.equal(actual, moment('2018-10-31').isHoliday(s)); | ||
} | ||
// 1.1.0 | ||
assert.deepEqual({ | ||
allStates: false, | ||
holidayName: 'Allerheiligen', | ||
holidayStates: [ 'BW' ], | ||
testedStates: ['BW', 'SH', 'TH'] | ||
}, moment('2018-11-01').isHoliday(['BW', 'SH', 'TH'])); | ||
holidayName: 'Reformationstag', | ||
holidayStates: after2017, | ||
testedStates: allStates | ||
}, moment('2018-10-31').isHoliday([])); | ||
}); |
13965
5
300