/* jshint -W117 */ const config = { 'loopback_url': 'http://test.test/', 'rss': { 'title': 'test rss', 'description': 'description', 'endpoint': '/rss', 'length': 2 }, }; const rss = require('../src/rss')(config); test('empty rss', () => { const xml = rss.get({}); expect(xml).toBe('' + '' + 'test rss' + 'description' + 'http://test.test/' + '' + new Date().toString() + '' + '' + new Date().toString() + '' + '60' + ''); }); test('1 item', () => { const data = { 'a': { path: 'a', realPath: 'b', year: 2019, month: 5, day: 5, date: new Date(2019, 5, 5), title: 'Title with : info !', thumbnail: '/2019/05/05/thumbnail.jpg/', escapedTitle: 'title_with___info', url: '/2019/05/05/title_with___info/', } }; const xml = rss.get(data); expect(xml).toEqual('' + '' + 'test rss' + 'description' + 'http://test.test/' + '' + new Date().toString() + '' + '' + new Date().toString() + '' + '60' + '' + 'Title with : info !' + 'http://test.test/2019/05/05/title_with___info/' + '' + new Date(2019, 5, 5).toString() + '' + '' + ''); }); test('3 items only 2 shown sorted', () => { const data = { 'a': { path: '2019/05/05', date: new Date(2019, 5, 5), title: 'a', url: 'a', }, 'b': { path: '2018/05/05', date: new Date(2018, 5, 5), title: 'b', url: 'b', }, 'c': { path: '2020/05/05', date: new Date(2020, 5, 5), title: 'c', url: 'c', } }; const xml = rss.get(data); expect(xml).toEqual('' + '' + 'test rss' + 'description' + 'http://test.test/' + '' + new Date().toString() + '' + '' + new Date().toString() + '' + '60' + '' + 'c' + 'http://test.test/c' + '' + new Date(2020, 5, 5).toString() + '' + '' + '' + 'a' + 'http://test.test/a' + '' + new Date(2019, 5, 5).toString() + '' + '' + ''); });