From 23407a3560434f7aa6f1b9a18eb7a3aca31c5b31 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Fri, 24 Jun 2022 12:39:08 -0700 Subject: [PATCH] Add unit test for shouldRenderBrief() --- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- src/common.js | 4 ++++ src/common.spec.js | 18 ++++++++++++++++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6587c25..00cb77c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@hebcal/rest-api", - "version": "3.18.0", + "version": "3.19.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hebcal/rest-api", - "version": "3.18.0", + "version": "3.19.0", "license": "BSD-2-Clause", "dependencies": { - "@hebcal/core": "^3.41.0", + "@hebcal/core": "^3.41.1", "@hebcal/leyning": "^4.13.3" }, "devDependencies": { @@ -1667,9 +1667,9 @@ } }, "node_modules/@hebcal/core": { - "version": "3.41.0", - "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.41.0.tgz", - "integrity": "sha512-gf+n/ARJtjmbDiGFUW6TMVztsfoy1ZdtbYjSglMOcQ+e4N48TkuRJpKl8v0Acl4FyDUZGHHINZ6e5SHBcbMpjg==", + "version": "3.41.1", + "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.41.1.tgz", + "integrity": "sha512-dYzf+Bs+SPW0kavYLEKccn4Wv1hw21idQCKiRYr7AfgOFq0DDhTQxs3Sym0yswmo22jdbySDiVdzB1ledLuorA==", "engines": { "node": ">=10.21.0" } @@ -7539,9 +7539,9 @@ } }, "@hebcal/core": { - "version": "3.41.0", - "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.41.0.tgz", - "integrity": "sha512-gf+n/ARJtjmbDiGFUW6TMVztsfoy1ZdtbYjSglMOcQ+e4N48TkuRJpKl8v0Acl4FyDUZGHHINZ6e5SHBcbMpjg==" + "version": "3.41.1", + "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.41.1.tgz", + "integrity": "sha512-dYzf+Bs+SPW0kavYLEKccn4Wv1hw21idQCKiRYr7AfgOFq0DDhTQxs3Sym0yswmo22jdbySDiVdzB1ledLuorA==" }, "@hebcal/leyning": { "version": "4.13.3", diff --git a/package.json b/package.json index 52dc095..a8a1f4c 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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": { diff --git a/src/common.js b/src/common.js index 0bb26d1..05f547e 100644 --- a/src/common.js +++ b/src/common.js @@ -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; } diff --git a/src/common.spec.js b/src/common.spec.js index 2bd762d..a758b5d 100644 --- a/src/common.spec.js +++ b/src/common.spec.js @@ -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', @@ -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); +});