mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
Рабочая версия
This commit is contained in:
@@ -1 +1 @@
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[Untitled]]></title><link>http://github.com/LightAir/turbo-rss</link><description><![CDATA[Untitled]]></description><language>ru</language></channel></rss>
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title/><link></link><description/><language>ru</language></channel></rss>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link></link><turbo:source></turbo:source><turbo:content><![CDATA[<header> <h1>No title</h1></header>undefined]]></turbo:content></item></channel></rss>
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link></link><turbo:content><![CDATA[<header> <h1></h1></header>undefined]]></turbo:content></item></channel></rss>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[Untitled]]></title><link>http://github.com/LightAir/turbo-rss</link><description><![CDATA[Untitled]]></description><language>ru</language><item turbo="true"><link></link><turbo:source></turbo:source><turbo:content><![CDATA[<header> <h1>No title</h1></header>undefined]]></turbo:content></item></channel></rss>
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title/><link></link><description/><language>ru</language><item turbo="true"><link></link><turbo:content><![CDATA[<header> <h1></h1></header>undefined]]></turbo:content></item></channel></rss>
|
||||
|
||||
1
test/expectedOutput/menu.xml
Normal file
1
test/expectedOutput/menu.xml
Normal file
@@ -0,0 +1 @@
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link>http://example.com/article4?this&that</link><pubDate>Sat, 26 May 2018 21:00:00 GMT</pubDate><author>LightAir</author><turbo:content><![CDATA[<header><figure><img src="http://example.com/example.png" /></figure> <h1>item title</h1><menu><a href="http://example.com/">Главная</a><a href="http://example.com/about">О сайте</a></menu></header><p>hello</p>]]></turbo:content><yandex:related type="infinity"><link url="http://example.com/related/post1" img="http://example.com/i/img1.jpg">related link text 1</link><link url="http://example.com/related/post2" img="http://example.com/i/img2.jpg">related link text 2</link></yandex:related></item><item turbo="true"><link></link><turbo:content><![CDATA[<header> <h1></h1></header>undefined]]></turbo:content></item></channel></rss>
|
||||
@@ -1 +1 @@
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link>http://example.com/article4?this&that</link><turbo:source>http://example.com/article4?this&that</turbo:source><pubDate>Sat, 26 May 2018 21:00:00 GMT</pubDate><author>LightAir</author><turbo:content><![CDATA[<header><figure><img src="http://example.com/example.png" /></figure> <h1>item title</h1><menu><a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a></menu></header><p>hello</p>]]></turbo:content><yandex:related><link url="http://example.com/related/post1" img="http://example.com/i/img1.jpg">related link text 1</link><link url="http://example.com/related/post2" img="http://example.com/i/img2.jpg">related link text 2</link></yandex:related></item></channel></rss>
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link>http://example.com/article4?this&that</link><pubDate>Sat, 26 May 2018 21:00:00 GMT</pubDate><author>LightAir</author><turbo:content><![CDATA[<header><figure><img src="http://example.com/example.png" /></figure> <h1>item title</h1></header><p>hello</p>]]></turbo:content><yandex:related><link url="http://example.com/related/post1" img="http://example.com/i/img1.jpg">related link text 1</link><link url="http://example.com/related/post2" img="http://example.com/i/img2.jpg">related link text 2</link></yandex:related></item></channel></rss>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link>http://example.com/article4?this&that</link><turbo:source>http://example.com/article4?this&that</turbo:source><pubDate>Sat, 26 May 2018 21:00:00 GMT</pubDate><author>LightAir</author><turbo:content><![CDATA[<header><figure><img src="http://example.com/example.png" /></figure> <h1>item title</h1></header><p>hello</p>]]></turbo:content><yandex:related type="infinity"><link url="http://example.com/related/post1" img="http://example.com/i/img1.jpg">related link text 1</link><link url="http://example.com/related/post2" img="http://example.com/i/img2.jpg">related link text 2</link></yandex:related></item></channel></rss>
|
||||
<rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" xmlns:turbo="http://turbo.yandex.ru" version="2.0"><channel><title><![CDATA[title]]></title><link>http://example.com/rss.xml</link><description><![CDATA[description]]></description><language>ru</language><item turbo="true"><link>http://example.com/article4?this&that</link><pubDate>Sat, 26 May 2018 21:00:00 GMT</pubDate><author>LightAir</author><turbo:content><![CDATA[<header><figure><img src="http://example.com/example.png" /></figure> <h1>item title</h1></header><p>hello</p>]]></turbo:content><yandex:related type="infinity"><link url="http://example.com/related/post1" img="http://example.com/i/img1.jpg">related link text 1</link><link url="http://example.com/related/post2" img="http://example.com/i/img2.jpg">related link text 2</link></yandex:related></item></channel></rss>
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
// use npm run test:browser to run tests in a browser
|
||||
const test = require('tape');
|
||||
|
||||
const YTurbo = require('..');
|
||||
const TR = require('..');
|
||||
|
||||
const includeFolder = require('include-folder');
|
||||
const expectedOutput = includeFolder(__dirname + '/expectedOutput', /.*\.xml$/);
|
||||
|
||||
require('mockdate').set('Wed, 10 Dec 2014 19:04:57 GMT');
|
||||
|
||||
test('empty feed', function(t) {
|
||||
test('empty feed', function (t) {
|
||||
t.plan(2);
|
||||
let feed = new YTurbo();
|
||||
let feed = new TR();
|
||||
t.equal(feed.xml(), expectedOutput.default.trim());
|
||||
feed.item();
|
||||
t.equal(feed.xml(), expectedOutput.defaultOneItem.trim());
|
||||
});
|
||||
|
||||
test('default item', function(t) {
|
||||
test('default item', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new YTurbo({
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
@@ -31,9 +31,9 @@ test('default item', function(t) {
|
||||
t.equal(feed.xml(), expectedOutput.defaultItem.trim());
|
||||
});
|
||||
|
||||
test('related item', function(t) {
|
||||
test('related item', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new YTurbo({
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
@@ -41,7 +41,7 @@ test('related item', function(t) {
|
||||
});
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
title: 'item title',
|
||||
image_url: 'http://example.com/example.png',
|
||||
url: 'http://example.com/article4?this&that',
|
||||
author: 'LightAir',
|
||||
@@ -62,9 +62,9 @@ test('related item', function(t) {
|
||||
t.equal(feed.xml(), expectedOutput.relatedItem.trim());
|
||||
});
|
||||
|
||||
test('related item', function(t) {
|
||||
test('related item', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new YTurbo({
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
@@ -72,7 +72,7 @@ test('related item', function(t) {
|
||||
});
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
title: 'item title',
|
||||
image_url: 'http://example.com/example.png',
|
||||
url: 'http://example.com/article4?this&that',
|
||||
author: 'LightAir',
|
||||
@@ -91,4 +91,44 @@ test('related item', function(t) {
|
||||
});
|
||||
|
||||
t.equal(feed.xml(), expectedOutput.relatedItemInfinity.trim());
|
||||
});
|
||||
});
|
||||
|
||||
test('menu', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
site_url: 'http://example.com'
|
||||
});
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
image_url: 'http://example.com/example.png',
|
||||
url: 'http://example.com/article4?this&that',
|
||||
author: 'LightAir',
|
||||
date: 'May 27, 2018 00:00 AM',
|
||||
content: '<p>hello</p>',
|
||||
relatedfinity: true,
|
||||
menu: [{
|
||||
link: 'http://example.com/',
|
||||
text: 'Главная',
|
||||
}, {
|
||||
link: 'http://example.com/about',
|
||||
text: 'О сайте',
|
||||
}],
|
||||
related: [{
|
||||
link: 'http://example.com/related/post1',
|
||||
image_url: 'http://example.com/i/img1.jpg',
|
||||
text: 'related link text 1'
|
||||
}, {
|
||||
link: 'http://example.com/related/post2',
|
||||
image_url: 'http://example.com/i/img2.jpg',
|
||||
text: 'related link text 2'
|
||||
}]
|
||||
});
|
||||
|
||||
feed.item({});
|
||||
|
||||
t.equal(feed.xml(), expectedOutput.menu.trim());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user