mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
Изменение тестов
This commit is contained in:
121
test/index.js
121
test/index.js
@@ -1,12 +1,28 @@
|
|||||||
/*
|
// prova is a wrapper for tape
|
||||||
* use npm test to run tests
|
// use npm run test:browser to run tests in a browser
|
||||||
*/
|
|
||||||
const test = require('tape');
|
const test = require('tape');
|
||||||
const TR = require('..');
|
const TR = require('..');
|
||||||
|
|
||||||
const includeFolder = require('include-folder');
|
const includeFolder = require('include-folder');
|
||||||
const expectedOutput = includeFolder(__dirname + '/expectedOutput', /.*\.xml$/);
|
const expectedOutput = includeFolder(__dirname + '/expectedOutput', /.*\.xml$/);
|
||||||
|
|
||||||
|
const baseOptions = {
|
||||||
|
title: 'title',
|
||||||
|
description: 'description',
|
||||||
|
link: 'http://example.com/rss.xml',
|
||||||
|
site_url: 'http://example.com'
|
||||||
|
};
|
||||||
|
|
||||||
|
const relatedOptions = [{
|
||||||
|
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'
|
||||||
|
}];
|
||||||
|
|
||||||
require('mockdate').set('Wed, 10 Dec 2014 19:04:57 GMT');
|
require('mockdate').set('Wed, 10 Dec 2014 19:04:57 GMT');
|
||||||
|
|
||||||
test('empty feed', function (t) {
|
test('empty feed', function (t) {
|
||||||
@@ -19,42 +35,16 @@ test('empty feed', function (t) {
|
|||||||
|
|
||||||
test('default item', function (t) {
|
test('default item', function (t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
let feed = new TR({
|
let feed = new TR(baseOptions);
|
||||||
title: 'title',
|
|
||||||
description: 'description',
|
|
||||||
link: 'http://example.com/rss.xml',
|
|
||||||
site_url: 'http://example.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
feed.item({});
|
feed.item({});
|
||||||
|
|
||||||
t.equal(feed.xml(), expectedOutput.defaultItem.trim());
|
t.equal(feed.xml(), expectedOutput.defaultItem.trim());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('default item turbo false', 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({
|
|
||||||
turboEnabled: false
|
|
||||||
});
|
|
||||||
|
|
||||||
t.equal(feed.xml(), expectedOutput.defaultItemTurboFalse.trim());
|
|
||||||
});
|
|
||||||
|
|
||||||
test('related item', function (t) {
|
test('related item', function (t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
let feed = new TR({
|
let feed = new TR(baseOptions);
|
||||||
title: 'title',
|
|
||||||
description: 'description',
|
|
||||||
link: 'http://example.com/rss.xml',
|
|
||||||
site_url: 'http://example.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
feed.item({
|
feed.item({
|
||||||
title: 'item title',
|
title: 'item title',
|
||||||
@@ -64,15 +54,7 @@ test('related item', function (t) {
|
|||||||
date: 'May 27, 2018 00:00 AM',
|
date: 'May 27, 2018 00:00 AM',
|
||||||
menu: '<a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a>',
|
menu: '<a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a>',
|
||||||
content: '<p>hello</p>',
|
content: '<p>hello</p>',
|
||||||
related: [{
|
related: relatedOptions
|
||||||
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'
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
t.equal(feed.xml(), expectedOutput.relatedItem.trim());
|
t.equal(feed.xml(), expectedOutput.relatedItem.trim());
|
||||||
@@ -80,12 +62,7 @@ test('related item', function (t) {
|
|||||||
|
|
||||||
test('related item', function (t) {
|
test('related item', function (t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
let feed = new TR({
|
let feed = new TR(baseOptions);
|
||||||
title: 'title',
|
|
||||||
description: 'description',
|
|
||||||
link: 'http://example.com/rss.xml',
|
|
||||||
site_url: 'http://example.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
feed.item({
|
feed.item({
|
||||||
title: 'item title',
|
title: 'item title',
|
||||||
@@ -95,15 +72,7 @@ test('related item', function (t) {
|
|||||||
date: 'May 27, 2018 00:00 AM',
|
date: 'May 27, 2018 00:00 AM',
|
||||||
content: '<p>hello</p>',
|
content: '<p>hello</p>',
|
||||||
relatedfinity: true,
|
relatedfinity: true,
|
||||||
related: [{
|
related: relatedOptions
|
||||||
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'
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
t.equal(feed.xml(), expectedOutput.relatedItemInfinity.trim());
|
t.equal(feed.xml(), expectedOutput.relatedItemInfinity.trim());
|
||||||
@@ -111,12 +80,7 @@ test('related item', function (t) {
|
|||||||
|
|
||||||
test('menu', function (t) {
|
test('menu', function (t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
let feed = new TR({
|
let feed = new TR(baseOptions);
|
||||||
title: 'title',
|
|
||||||
description: 'description',
|
|
||||||
link: 'http://example.com/rss.xml',
|
|
||||||
site_url: 'http://example.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
feed.item({
|
feed.item({
|
||||||
title: 'item title',
|
title: 'item title',
|
||||||
@@ -133,15 +97,7 @@ test('menu', function (t) {
|
|||||||
link: 'http://example.com/about',
|
link: 'http://example.com/about',
|
||||||
text: 'О сайте',
|
text: 'О сайте',
|
||||||
}],
|
}],
|
||||||
related: [{
|
related: relatedOptions
|
||||||
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({});
|
feed.item({});
|
||||||
@@ -151,12 +107,7 @@ test('menu', function (t) {
|
|||||||
|
|
||||||
test('goals', function (t) {
|
test('goals', function (t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
let feed = new TR({
|
let feed = new TR(baseOptions);
|
||||||
title: 'title',
|
|
||||||
description: 'description',
|
|
||||||
link: 'http://example.com/rss.xml',
|
|
||||||
site_url: 'http://example.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
feed.item({
|
feed.item({
|
||||||
title: 'item title',
|
title: 'item title',
|
||||||
@@ -166,21 +117,13 @@ test('goals', function (t) {
|
|||||||
date: 'May 27, 2018 00:00 AM',
|
date: 'May 27, 2018 00:00 AM',
|
||||||
menu: '<a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a>',
|
menu: '<a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a>',
|
||||||
goals: [{
|
goals: [{
|
||||||
type: "yandex",
|
type: 'yandex',
|
||||||
id: "turbo-goal-id",
|
id: 'turbo-goal-id',
|
||||||
counter_id: "12345",
|
counter_id: '12345',
|
||||||
name: "order",
|
name: 'order',
|
||||||
}],
|
}],
|
||||||
content: '<p>hello</p>',
|
content: '<p>hello</p>',
|
||||||
related: [{
|
related: relatedOptions
|
||||||
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'
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
t.equal(feed.xml(), expectedOutput.goal.trim());
|
t.equal(feed.xml(), expectedOutput.goal.trim());
|
||||||
|
|||||||
Reference in New Issue
Block a user