-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathTimedEvent.spec.ts
45 lines (41 loc) · 2.31 KB
/
TimedEvent.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {expect, test} from 'vitest';
import {TimedEvent, CandleLightingEvent, HavdalahEvent} from '../src/TimedEvent';
import {flags} from '../src/event';
import {HDate} from '@hebcal/hdate';
import {Location} from '../src/location';
test('renderBrief', () => {
const dt = new Date('2020-12-28T20:12:14.987Z');
const hd = new HDate(dt);
const location = new Location(0, 0, false, 'UTC', undefined, 'GB');
const timed = new TimedEvent(hd, 'Foo Bar', 0, dt, location);
const candleLighting = new CandleLightingEvent(hd, flags.LIGHT_CANDLES, dt, location);
const havdalah = new HavdalahEvent(hd, flags.LIGHT_CANDLES_TZEIS, dt, location, 42);
const havdalahTzeit = new HavdalahEvent(hd, flags.LIGHT_CANDLES_TZEIS, dt, location);
expect(timed.getDesc()).toBe('Foo Bar');
expect(timed.render('en')).toBe('Foo Bar: 20:12');
expect(timed.renderBrief('en')).toBe('Foo Bar');
expect(candleLighting.getDesc()).toBe('Candle lighting');
expect(candleLighting.render('en')).toBe('Candle lighting: 20:12');
expect(candleLighting.renderBrief('en')).toBe('Candle lighting');
expect(havdalah.getDesc()).toBe('Havdalah');
expect(havdalah.render('en')).toBe('Havdalah (42 min): 20:12');
expect(havdalah.renderBrief('en')).toBe('Havdalah (42 min)');
expect(havdalahTzeit.getDesc()).toBe('Havdalah');
expect(havdalahTzeit.render('en')).toBe('Havdalah: 20:12');
expect(havdalahTzeit.renderBrief('en')).toBe('Havdalah');
expect(candleLighting.render('he')).toBe('הַדְלָקַת נֵרוֹת: 20:12');
expect(candleLighting.renderBrief('he')).toBe('הַדְלָקַת נֵרוֹת');
expect(havdalah.render('he')).toBe('הַבְדָּלָה (42 דַּקּוֹת): 20:12');
expect(havdalah.renderBrief('he')).toBe('הַבְדָּלָה (42 דַּקּוֹת)');
expect(havdalahTzeit.render('he')).toBe('הַבְדָּלָה: 20:12');
expect(havdalahTzeit.renderBrief('he')).toBe('הַבְדָּלָה');
});
test('emoji', () => {
const dt = new Date('2020-12-28T20:12:14.987Z');
const hd = new HDate(dt);
const location = new Location(0, 0, false, 'UTC');
const candleLighting = new CandleLightingEvent(hd, flags.LIGHT_CANDLES, dt, location);
const havdalah = new HavdalahEvent(hd, flags.LIGHT_CANDLES_TZEIS, dt, location);
expect(candleLighting.getEmoji()).toBe('🕯️');
expect(havdalah.getEmoji()).toBe('✨');
});