Skip to content

Commit

Permalink
Add unit test for shouldRenderBrief()
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jun 24, 2022
1 parent feb4391 commit 23407a3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/rest-api",
"version": "3.19.0",
"version": "3.19.1",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand All @@ -21,7 +21,7 @@
"url": "https://github.com/hebcal/hebcal-rest-api/issues"
},
"dependencies": {
"@hebcal/core": "^3.41.0",
"@hebcal/core": "^3.41.1",
"@hebcal/leyning": "^4.13.3"
},
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ export function shouldRenderBrief(ev) {
return (hd.getDate() === 1) ? false : true;
} else if (mask & flags.DAF_YOMI) {
return true;
} else if (mask & flags.MINOR_FAST && ev.getDesc().substring(0, 16) === 'Yom Kippur Katan') {
return true;
} else if (mask & flags.SHABBAT_MEVARCHIM) {
return true;
} else {
return false;
}
Expand Down
18 changes: 16 additions & 2 deletions src/common.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';
import {getDownloadFilename, getCalendarTitle, makeTorahMemoText, getEventCategories,
getHolidayDescription,
appendIsraelAndTracking, locationToPlainObj} from './common';
import {HebrewCalendar, Location, Event, HDate, flags, HolidayEvent} from '@hebcal/core';
appendIsraelAndTracking, locationToPlainObj, shouldRenderBrief} from './common';
import {HebrewCalendar, Location, Event, HDate, flags, HolidayEvent, HebrewDateEvent, TimedEvent, DafYomiEvent} from '@hebcal/core';

test('getDownloadFilename', (t) => {
const location = new Location(38.672294, -90.533239, false, 'America/Chicago',
Expand Down Expand Up @@ -280,3 +280,17 @@ test('getHolidayDescription-notfound', (t) => {
const s = getHolidayDescription(ev);
t.is(s, '');
});

test('shouldRenderBrief', (t) => {
t.is(shouldRenderBrief(new HolidayEvent(new HDate(17, 'Tevet', 5784), 'Asara B\'Tevet', flags.MINOR_FAST)), false);
t.is(shouldRenderBrief(new HolidayEvent(new HDate(29, 'Tevet', 5784), 'Yom Kippur Katan', flags.MINOR_FAST)), true);
t.is(shouldRenderBrief(new HolidayEvent(new HDate(14, 'Nisan', 5784), 'Erev Pesach', flags.EREV)), false);
t.is(shouldRenderBrief(new HebrewDateEvent(new HDate(1, 'Nisan', 5784))), false);
t.is(shouldRenderBrief(new HebrewDateEvent(new HDate(2, 'Nisan', 5784))), true);
t.is(shouldRenderBrief(new Event(new HDate(new Date('1959-11-28')),
'Shabbat Mevarchim Chodesh Kislev', flags.SHABBAT_MEVARCHIM)), true);
t.is(shouldRenderBrief(new TimedEvent(new HDate(25, 'Sivan', 5782),
'Candle lighting: 8:15pm', flags.LIGHT_CANDLES,
new Date(), Location.lookup('Boston'))), true);
t.is(shouldRenderBrief(new DafYomiEvent(new HDate(25, 'Sivan', 5782))), true);
});

0 comments on commit 23407a3

Please sign in to comment.