smartfeed/test/test.ts

41 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-10-25 00:09:33 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartfeed from '../ts/index';
2020-10-25 14:02:03 +00:00
let testSmartFeed: smartfeed.Smartfeed;
tap.test('should create a feedVersion', async () => {
testSmartFeed = new smartfeed.Smartfeed();
expect(testSmartFeed).to.be.instanceOf(smartfeed.Smartfeed);
2020-10-25 00:09:33 +00:00
});
2020-10-25 20:07:35 +00:00
tap.test('should create a feed', async () => {
const feed = testSmartFeed.createFeed({
domain: 'central.eu',
title: 'central.eu - ideas for Europe',
category: 'Politics',
company: 'Lossless GmbH',
companyDomain: 'https://lossless.com',
companyEmail: 'hello@lossless.com',
description: 'ideas for Europe',
});
feed.addItem({
title: 'A better European Union',
authorName: 'Phil',
imageUrl: 'https://central.eu/someimage.png',
timestamp: Date.now(),
2020-11-11 10:11:18 +00:00
url: 'https://central.eu/article/somearticle',
content: 'somecontent'
2020-10-25 20:07:35 +00:00
});
const rssFeed = feed.exportRssFeedString();
console.log(rssFeed);
2020-10-25 22:11:00 +00:00
const parsedFeed = await testSmartFeed.parseFeedFromString(rssFeed);
console.log(parsedFeed);
});
tap.test('should parse a Url', async () => {
const result = await testSmartFeed.parseFeedFromUrl('https://www.theverge.com/rss/index.xml');
// console.log(result);
2020-10-25 20:07:35 +00:00
});
2020-10-25 00:09:33 +00:00
tap.start();