mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 20:16:19 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cccd65768 | ||
|
|
812a429d9b | ||
|
|
15c9715cee | ||
|
|
816b6b5690 | ||
|
|
ef90f974bd | ||
|
|
8aa086865d |
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "turbo-rss",
|
"name": "turbo-rss",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"description": "RSS based, feed generator for Yandex turbo",
|
"description": "RSS based, feed generator for Yandex turbo",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"yandex",
|
"yandex",
|
||||||
@@ -10,8 +10,7 @@
|
|||||||
],
|
],
|
||||||
"main": "lib/index",
|
"main": "lib/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tape test --tap | tap-difflet",
|
"test": "tape test --tap | tap-min"
|
||||||
"coverage": "istanbul cover tape test -- -R spec"
|
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/LightAir/turbo-rss",
|
"homepage": "https://github.com/LightAir/turbo-rss",
|
||||||
"author": {
|
"author": {
|
||||||
@@ -56,27 +55,12 @@
|
|||||||
"xml": "1.0.1"
|
"xml": "1.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^4.19.1",
|
"eslint": "^7.28.0",
|
||||||
"folderify": "^1.1.0",
|
|
||||||
"grunt": "^0.4.5",
|
|
||||||
"grunt-cli": "^0.1.13",
|
|
||||||
"grunt-contrib-jshint": "^0.11.3",
|
|
||||||
"grunt-release": "^0.13.0",
|
|
||||||
"grunt-templates-dylang": "^1.0.10",
|
|
||||||
"include-folder": "^1.0.0",
|
"include-folder": "^1.0.0",
|
||||||
"load-grunt-tasks": "^3.3.0",
|
"mockdate": "^3.0.5",
|
||||||
"mockdate": "^1.0.3",
|
"q": "^1.5.1",
|
||||||
"prova": "^2.1.2",
|
"tap-min": "~2.0.0",
|
||||||
"q": "^1.4.1",
|
"tape": "^5.2.2"
|
||||||
"tap-difflet": "^0.4.0",
|
|
||||||
"tape": "^4.2.1",
|
|
||||||
"time-grunt": "^1.2.1",
|
|
||||||
"xml2js": "^0.4.12"
|
|
||||||
},
|
|
||||||
"browserify": {
|
|
||||||
"transform": [
|
|
||||||
"folderify"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ feed.item({
|
|||||||
}, {
|
}, {
|
||||||
link: 'http://example.com/about',
|
link: 'http://example.com/about',
|
||||||
text: 'О сайте'
|
text: 'О сайте'
|
||||||
}]
|
}],
|
||||||
related: [{
|
related: [{
|
||||||
link: 'http://example.com/related/post1',
|
link: 'http://example.com/related/post1',
|
||||||
image_url: 'http://example.com/i/img1.jpg',
|
image_url: 'http://example.com/i/img1.jpg',
|
||||||
@@ -126,4 +126,4 @@ $ npm test
|
|||||||
|
|
||||||
@vvmspace
|
@vvmspace
|
||||||
|
|
||||||
@crackosok
|
@crackosok
|
||||||
|
|||||||
119
test/index.js
119
test/index.js
@@ -1,12 +1,26 @@
|
|||||||
/*
|
|
||||||
* use npm test to run tests
|
|
||||||
*/
|
|
||||||
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 +33,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 +52,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 +60,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 +70,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 +78,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 +95,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 +105,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 +115,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