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",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "RSS based, feed generator for Yandex turbo",
|
||||
"keywords": [
|
||||
"yandex",
|
||||
@@ -10,8 +10,7 @@
|
||||
],
|
||||
"main": "lib/index",
|
||||
"scripts": {
|
||||
"test": "tape test --tap | tap-difflet",
|
||||
"coverage": "istanbul cover tape test -- -R spec"
|
||||
"test": "tape test --tap | tap-min"
|
||||
},
|
||||
"homepage": "https://github.com/LightAir/turbo-rss",
|
||||
"author": {
|
||||
@@ -56,27 +55,12 @@
|
||||
"xml": "1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^4.19.1",
|
||||
"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",
|
||||
"eslint": "^7.28.0",
|
||||
"include-folder": "^1.0.0",
|
||||
"load-grunt-tasks": "^3.3.0",
|
||||
"mockdate": "^1.0.3",
|
||||
"prova": "^2.1.2",
|
||||
"q": "^1.4.1",
|
||||
"tap-difflet": "^0.4.0",
|
||||
"tape": "^4.2.1",
|
||||
"time-grunt": "^1.2.1",
|
||||
"xml2js": "^0.4.12"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
"folderify"
|
||||
]
|
||||
"mockdate": "^3.0.5",
|
||||
"q": "^1.5.1",
|
||||
"tap-min": "~2.0.0",
|
||||
"tape": "^5.2.2"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ feed.item({
|
||||
}, {
|
||||
link: 'http://example.com/about',
|
||||
text: 'О сайте'
|
||||
}]
|
||||
}],
|
||||
related: [{
|
||||
link: 'http://example.com/related/post1',
|
||||
image_url: 'http://example.com/i/img1.jpg',
|
||||
@@ -126,4 +126,4 @@ $ npm test
|
||||
|
||||
@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 TR = require('..');
|
||||
|
||||
const includeFolder = require('include-folder');
|
||||
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');
|
||||
|
||||
test('empty feed', function (t) {
|
||||
@@ -19,42 +33,16 @@ test('empty feed', function (t) {
|
||||
|
||||
test('default item', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
site_url: 'http://example.com'
|
||||
});
|
||||
let feed = new TR(baseOptions);
|
||||
|
||||
feed.item({});
|
||||
|
||||
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) {
|
||||
t.plan(1);
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
site_url: 'http://example.com'
|
||||
});
|
||||
let feed = new TR(baseOptions);
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
@@ -64,15 +52,7 @@ test('related item', function (t) {
|
||||
date: 'May 27, 2018 00:00 AM',
|
||||
menu: '<a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a>',
|
||||
content: '<p>hello</p>',
|
||||
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'
|
||||
}]
|
||||
related: relatedOptions
|
||||
});
|
||||
|
||||
t.equal(feed.xml(), expectedOutput.relatedItem.trim());
|
||||
@@ -80,12 +60,7 @@ test('related item', function (t) {
|
||||
|
||||
test('related item', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
site_url: 'http://example.com'
|
||||
});
|
||||
let feed = new TR(baseOptions);
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
@@ -95,15 +70,7 @@ test('related item', function (t) {
|
||||
date: 'May 27, 2018 00:00 AM',
|
||||
content: '<p>hello</p>',
|
||||
relatedfinity: true,
|
||||
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'
|
||||
}]
|
||||
related: relatedOptions
|
||||
});
|
||||
|
||||
t.equal(feed.xml(), expectedOutput.relatedItemInfinity.trim());
|
||||
@@ -111,12 +78,7 @@ test('related item', function (t) {
|
||||
|
||||
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'
|
||||
});
|
||||
let feed = new TR(baseOptions);
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
@@ -133,15 +95,7 @@ test('menu', function (t) {
|
||||
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'
|
||||
}]
|
||||
related: relatedOptions
|
||||
});
|
||||
|
||||
feed.item({});
|
||||
@@ -151,12 +105,7 @@ test('menu', function (t) {
|
||||
|
||||
test('goals', function (t) {
|
||||
t.plan(1);
|
||||
let feed = new TR({
|
||||
title: 'title',
|
||||
description: 'description',
|
||||
link: 'http://example.com/rss.xml',
|
||||
site_url: 'http://example.com'
|
||||
});
|
||||
let feed = new TR(baseOptions);
|
||||
|
||||
feed.item({
|
||||
title: 'item title',
|
||||
@@ -166,21 +115,13 @@ test('goals', function (t) {
|
||||
date: 'May 27, 2018 00:00 AM',
|
||||
menu: '<a href="http://example.com/page1.html">Текст ссылки</a> <a href="http://example.com/page2.html">Текст ссылки</a>',
|
||||
goals: [{
|
||||
type: "yandex",
|
||||
id: "turbo-goal-id",
|
||||
counter_id: "12345",
|
||||
name: "order",
|
||||
type: 'yandex',
|
||||
id: 'turbo-goal-id',
|
||||
counter_id: '12345',
|
||||
name: 'order',
|
||||
}],
|
||||
content: '<p>hello</p>',
|
||||
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'
|
||||
}]
|
||||
related: relatedOptions
|
||||
});
|
||||
|
||||
t.equal(feed.xml(), expectedOutput.goal.trim());
|
||||
|
||||
Reference in New Issue
Block a user