mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
Рабочая версия
This commit is contained in:
@@ -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