@@ -3,6 +3,13 @@ import test from 'ava';
3
3
import { HebrewCalendar , Location } from '@hebcal/core' ;
4
4
import { eventsToRss , eventToRssItem } from './rss' ;
5
5
6
+ const dayFormat = new Intl . DateTimeFormat ( 'en-US' , {
7
+ weekday : 'long' ,
8
+ day : '2-digit' ,
9
+ month : 'long' ,
10
+ year : 'numeric' ,
11
+ } ) ;
12
+
6
13
test ( 'eventsToRss' , ( t ) => {
7
14
const location = new Location ( 41.85003 , - 87.65005 , false , 'America/Chicago' , 'Chicago' , 'US' , 4887398 ) ;
8
15
const options = {
@@ -41,19 +48,14 @@ test('eventToRssItem', (t) => {
41
48
location : location ,
42
49
} ;
43
50
const events = HebrewCalendar . calendar ( options ) . slice ( 0 , 3 ) ;
44
- const dayFormat = new Intl . DateTimeFormat ( 'en-US' , {
45
- weekday : 'long' ,
46
- day : '2-digit' ,
47
- month : 'long' ,
48
- year : 'numeric' ,
49
- } ) ;
50
51
const lastBuildDate = 'Mon, 22 Jun 2020 20:03:18 GMT' ;
51
- const items = events . map ( ( ev ) => eventToRssItem ( ev , true , lastBuildDate , dayFormat , location ) ) ;
52
+ const mainUrl = 'https://www.hebcal.com/shabbat?city=Eilat' ;
53
+ const items = events . map ( ( ev ) => eventToRssItem ( ev , true , lastBuildDate , dayFormat , location , mainUrl ) ) ;
52
54
const expected = [
53
55
'<item>\n' +
54
56
'<title>Candle lighting: 18:43</title>\n' +
55
- '<link>https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=1990-04-06T15%3A43%3A00#candle-lighting</link>\n' +
56
- '<guid isPermaLink="false">https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=1990-04-06T15%3A43%3A00#candle-lighting</guid>\n' +
57
+ '<link>https://www.hebcal.com/shabbat?city=Eilat& utm_source=shabbat1c&utm_medium=rss&dt=1990-04-06T15%3A43%3A00#candle-lighting</link>\n' +
58
+ '<guid isPermaLink="false">https://www.hebcal.com/shabbat?city=Eilat& utm_source=shabbat1c&utm_medium=rss&dt=1990-04-06T15%3A43%3A00#candle-lighting</guid>\n' +
57
59
'<description>Friday, April 06, 1990</description>\n' +
58
60
'<category>candles</category>\n' +
59
61
'<pubDate>Fri, 06 Apr 1990 15:43:00 GMT</pubDate>\n' +
@@ -62,8 +64,8 @@ test('eventToRssItem', (t) => {
62
64
'</item>\n' ,
63
65
'<item>\n' +
64
66
'<title>Havdalah (50 min): 19:52</title>\n' +
65
- '<link>https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=1990-04-07T16%3A52%3A00#havdalah</link>\n' +
66
- '<guid isPermaLink="false">https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=1990-04-07T16%3A52%3A00#havdalah</guid>\n' +
67
+ '<link>https://www.hebcal.com/shabbat?city=Eilat& utm_source=shabbat1c&utm_medium=rss&dt=1990-04-07T16%3A52%3A00#havdalah</link>\n' +
68
+ '<guid isPermaLink="false">https://www.hebcal.com/shabbat?city=Eilat& utm_source=shabbat1c&utm_medium=rss&dt=1990-04-07T16%3A52%3A00#havdalah</guid>\n' +
67
69
'<description>Saturday, April 07, 1990</description>\n' +
68
70
'<category>havdalah</category>\n' +
69
71
'<pubDate>Sat, 07 Apr 1990 16:52:00 GMT</pubDate>\n' +
@@ -86,14 +88,8 @@ test('parsha', (t) => {
86
88
end : new Date ( 2020 , 10 , 28 ) ,
87
89
sedrot : true ,
88
90
} ) ;
89
- const dayFormat = new Intl . DateTimeFormat ( 'en-US' , {
90
- weekday : 'long' ,
91
- day : '2-digit' ,
92
- month : 'long' ,
93
- year : 'numeric' ,
94
- } ) ;
95
91
const location = Location . lookup ( 'Kiev' ) ;
96
- const item = eventToRssItem ( events [ 0 ] , true , '' , dayFormat , location ) ;
92
+ const item = eventToRssItem ( events [ 0 ] , true , '' , dayFormat , location , '' ) ;
97
93
const expected = '<item>\n' +
98
94
'<title>Parashat Vayetzei</title>\n' +
99
95
'<link>https://www.hebcal.com/sedrot/vayetzei-20201128?utm_source=shabbat1c&utm_medium=rss</link>\n' +
@@ -105,6 +101,25 @@ test('parsha', (t) => {
105
101
t . is ( item , expected ) ;
106
102
} ) ;
107
103
104
+ test ( 'parsha-il' , ( t ) => {
105
+ const events = HebrewCalendar . calendar ( {
106
+ start : new Date ( 2020 , 10 , 28 ) ,
107
+ end : new Date ( 2020 , 10 , 28 ) ,
108
+ sedrot : true ,
109
+ } ) ;
110
+ const location = Location . lookup ( 'Jerusalem' ) ;
111
+ const item = eventToRssItem ( events [ 0 ] , true , '' , dayFormat , location , '' ) ;
112
+ const expected = '<item>\n' +
113
+ '<title>Parashat Vayetzei</title>\n' +
114
+ '<link>https://www.hebcal.com/sedrot/vayetzei-20201128?i=on&utm_source=shabbat1c&utm_medium=rss</link>\n' +
115
+ '<guid isPermaLink="false">https://www.hebcal.com/sedrot/vayetzei-20201128?i=on&utm_source=shabbat1c&utm_medium=rss&dt=2020-11-28</guid>\n' +
116
+ '<description>Saturday, November 28, 2020</description>\n' +
117
+ '<category>parashat</category>\n' +
118
+ '<pubDate>Sat, 28 Nov 2020 00:00:00 GMT</pubDate>\n' +
119
+ '</item>\n' ;
120
+ t . is ( item , expected ) ;
121
+ } ) ;
122
+
108
123
test ( 'fastStartEnd' , ( t ) => {
109
124
const location = Location . lookup ( 'Tel Aviv' ) ;
110
125
const options = {
@@ -115,19 +130,14 @@ test('fastStartEnd', (t) => {
115
130
candlelighting : true ,
116
131
} ;
117
132
const events = HebrewCalendar . calendar ( options ) ;
118
- const dayFormat = new Intl . DateTimeFormat ( 'en-US' , {
119
- weekday : 'long' ,
120
- day : '2-digit' ,
121
- month : 'long' ,
122
- year : 'numeric' ,
123
- } ) ;
124
133
const lastBuildDate = 'Mon, 22 Jun 2020 20:03:18 GMT' ;
125
- const items = events . map ( ( ev ) => eventToRssItem ( ev , true , lastBuildDate , dayFormat , location ) ) ;
134
+ const mainUrl = 'https://www.hebcal.com/shabbat?city=Tel+Aviv' ;
135
+ const items = events . map ( ( ev ) => eventToRssItem ( ev , true , lastBuildDate , dayFormat , location , mainUrl ) ) ;
126
136
const expected = [
127
137
'<item>\n' +
128
138
'<title>Fast begins: 04:09</title>\n' +
129
- '<link>https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T01%3A09%3A00#fast-begins</link>\n' +
130
- '<guid isPermaLink="false">https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T01%3A09%3A00#fast-begins</guid>\n' +
139
+ '<link>https://www.hebcal.com/shabbat?city=Tel+Aviv& utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T01%3A09%3A00#fast-begins</link>\n' +
140
+ '<guid isPermaLink="false">https://www.hebcal.com/shabbat?city=Tel+Aviv& utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T01%3A09%3A00#fast-begins</guid>\n' +
131
141
'<description>Sunday, June 27, 2021</description>\n' +
132
142
'<category>zmanim</category>\n' +
133
143
'<pubDate>Sun, 27 Jun 2021 01:09:00 GMT</pubDate>\n' +
@@ -142,8 +152,8 @@ test('fastStartEnd', (t) => {
142
152
'</item>\n' ,
143
153
'<item>\n' +
144
154
'<title>Fast ends: 20:25</title>\n' +
145
- '<link>https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T17%3A25%3A00#fast-ends</link>\n' +
146
- '<guid isPermaLink="false">https://www.hebcal.com/shabbat?utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T17%3A25%3A00#fast-ends</guid>\n' +
155
+ '<link>https://www.hebcal.com/shabbat?city=Tel+Aviv& utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T17%3A25%3A00#fast-ends</link>\n' +
156
+ '<guid isPermaLink="false">https://www.hebcal.com/shabbat?city=Tel+Aviv& utm_source=shabbat1c&utm_medium=rss&dt=2021-06-27T17%3A25%3A00#fast-ends</guid>\n' +
147
157
'<description>Sunday, June 27, 2021</description>\n' +
148
158
'<category>zmanim</category>\n' +
149
159
'<pubDate>Sun, 27 Jun 2021 17:25:00 GMT</pubDate>\n' +
0 commit comments