mirror of
https://github.com/LightAir/turbo-rss.git
synced 2026-02-04 03:56:19 +00:00
Небольшие правки. Добавил тесты на новый функционал от crackosok
This commit is contained in:
@@ -73,7 +73,7 @@ function items(items, channel) {
|
||||
|
||||
if (item.goals.length > 0) {
|
||||
item.goals.forEach(goal => item_values.push({
|
||||
"turbo:goal": {
|
||||
'turbo:goal': {
|
||||
_attr: {
|
||||
type: goal.type || 'yandex',
|
||||
'turbo-goal-id': goal.id,
|
||||
@@ -81,7 +81,7 @@ function items(items, channel) {
|
||||
id: goal.counter_id,
|
||||
}
|
||||
}
|
||||
}))
|
||||
}));
|
||||
}
|
||||
|
||||
item_values.push({'turbo:content': {_cdata: fullContent}});
|
||||
@@ -143,7 +143,7 @@ function itemData(data) {
|
||||
turboSource: data.turboSource || '',
|
||||
turboTopic: data.turboTopic || '',
|
||||
goals: data.goals || [],
|
||||
turboEnabled: data.turboEnabled || true,
|
||||
turboEnabled: data.turboEnabled !== undefined ? data.turboEnabled: true,
|
||||
};
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "turbo-rss",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "RSS based, feed generator for Yandex turbo",
|
||||
"keywords": [
|
||||
"yandex",
|
||||
|
||||
10
readme.md
10
readme.md
@@ -46,7 +46,7 @@ feed.item(itemOptions);
|
||||
* `turboSource` _optional_ **string** URL страницы-источника, который можно передать в Яндекс.Метрику.
|
||||
* `turboTopic` _optional_ **string** Заголовок страницы, который можно передать в Яндекс.Метрику.
|
||||
* `goals` _optional_ **array** массив типа: { _id_ - внутренний идентификатор цели (turbo-goal-id), _name_ - имя цели, _counter_id_ - id счётчика яндекс-метрики }
|
||||
|
||||
* `turboEnabled`_optional_ **bool** Принудительная установка атрибута "turbo". По умолчанию true. Установка в false позволит скрыть отображение турбо-страницы
|
||||
###### menu array
|
||||
menu должен содержать массив объектов со следующими опциями:
|
||||
|
||||
@@ -119,3 +119,11 @@ var xml = feed.xml();
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## Спасибо
|
||||
|
||||
@jahglow
|
||||
|
||||
@vvmspace
|
||||
|
||||
@crackosok
|
||||
1
test/expectedOutput/defaultItemTurboFalse.xml
Normal file
1
test/expectedOutput/defaultItemTurboFalse.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="false"><link></link><turbo:content><![CDATA[<header> <h1></h1></header>undefined]]></turbo:content></item></channel></rss>
|
||||
@@ -1,7 +1,7 @@
|
||||
// prova is a wrapper for tape
|
||||
// use npm run test:browser to run tests in a browser
|
||||
/*
|
||||
* use npm test to run tests
|
||||
*/
|
||||
const test = require('tape');
|
||||
|
||||
const TR = require('..');
|
||||
|
||||
const includeFolder = require('include-folder');
|
||||
@@ -31,6 +31,22 @@ test('default item', function (t) {
|
||||
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({
|
||||
|
||||
Reference in New Issue
Block a user