1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 | const parse = require('./lib/parse')
|
6 | const { test } = require('tap')
|
7 |
|
8 | test('updated populated by lastBuildDate', (t) => {
|
9 | const xml = [
|
10 | '<rss><channel>',
|
11 | '<lastBuildDate>2018-12-27T23:29:49+0000</lastBuildDate>',
|
12 | '</channel></rss>'
|
13 | ].join()
|
14 |
|
15 | const wanted = [
|
16 | ['feed', {
|
17 | updated: '2018-12-27T23:29:49+0000'
|
18 | }],
|
19 | ['finish'],
|
20 | ['end']
|
21 | ]
|
22 |
|
23 | parse({ t: t, xml: xml, wanted: wanted }, (er) => {
|
24 | t.ok(!er)
|
25 | t.end()
|
26 | })
|
27 | })
|
28 |
|
29 | test('pubDate overrides lastBuildDate', (t) => {
|
30 | const xml = [
|
31 | '<rss><channel>',
|
32 | '<lastBuildDate>2018-12-27T23:29:49+0000</lastBuildDate>',
|
33 | '<pubDate>2018-12-27T23:29:50+0000</pubDate>',
|
34 | '</channel></rss>'
|
35 | ].join()
|
36 |
|
37 | const wanted = [
|
38 | ['feed', {
|
39 | updated: '2018-12-27T23:29:50+0000'
|
40 | }],
|
41 | ['finish'],
|
42 | ['end']
|
43 | ]
|
44 |
|
45 | parse({ t: t, xml: xml, wanted: wanted }, (er) => {
|
46 | t.ok(!er)
|
47 | t.end()
|
48 | })
|
49 | })
|
50 |
|
51 | test('pubDate overrides lastBuildDate in any order', (t) => {
|
52 | const xml = [
|
53 | '<rss><channel>',
|
54 | '<pubDate>2018-12-27T23:29:50+0000</pubDate>',
|
55 | '<lastBuildDate>2018-12-27T23:29:49+0000</lastBuildDate>',
|
56 | '</channel></rss>'
|
57 | ].join()
|
58 |
|
59 | const wanted = [
|
60 | ['feed', {
|
61 | updated: '2018-12-27T23:29:50+0000'
|
62 | }],
|
63 | ['finish'],
|
64 | ['end']
|
65 | ]
|
66 |
|
67 | parse({ t: t, xml: xml, wanted: wanted }, (er) => {
|
68 | t.ok(!er)
|
69 | t.end()
|
70 | })
|
71 | })
|