mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add missing files
This commit is contained in:
parent
a08af0610a
commit
0cae728a43
4 changed files with 2039 additions and 1 deletions
1994
packages/content-fetch/test/the-atlantic-article.html
Normal file
1994
packages/content-fetch/test/the-atlantic-article.html
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -36,6 +36,7 @@ import { TwitterHandler } from './websites/twitter-handler'
|
|||
import { WeixinQqHandler } from './websites/weixin-qq-handler'
|
||||
import { WikipediaHandler } from './websites/wikipedia-handler'
|
||||
import { YoutubeHandler } from './websites/youtube-handler'
|
||||
import { TheAtlanticHandler } from './websites/the-atlantic-handler'
|
||||
|
||||
const validateUrlString = (url: string): boolean => {
|
||||
const u = new URL(url)
|
||||
|
|
@ -56,6 +57,7 @@ const validateUrlString = (url: string): boolean => {
|
|||
}
|
||||
|
||||
const contentHandlers: ContentHandler[] = [
|
||||
new TheAtlanticHandler(),
|
||||
new AppleNewsHandler(),
|
||||
new BloombergHandler(),
|
||||
new DerstandardHandler(),
|
||||
|
|
|
|||
42
packages/content-handler/test/the-atlantic-handler.test.ts
Normal file
42
packages/content-handler/test/the-atlantic-handler.test.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { TheAtlanticHandler } from '../src/websites/the-atlantic-handler'
|
||||
import fs from 'fs';
|
||||
import nock from 'nock'
|
||||
|
||||
describe('Testing the atlantic opening', () => {
|
||||
const load = (path: string): string => {
|
||||
return fs.readFileSync(path, 'utf8')
|
||||
}
|
||||
|
||||
|
||||
before(() => {
|
||||
const html = load('./test/data/the-atlantic-article.html');
|
||||
nock('https://theatlantic.com').get('/article/').reply(200, html)
|
||||
})
|
||||
|
||||
it('should parse the title of the atlantic article.', async () => {
|
||||
const response = await new TheAtlanticHandler().preHandle(
|
||||
'https://theatlantic.com/article/'
|
||||
);
|
||||
|
||||
// We grab the title from the doucment.
|
||||
expect(response.title).not.toBeFalsy()
|
||||
})
|
||||
|
||||
it('should remove the article section, and replace it with a parseable div', async () => {
|
||||
const response = await new TheAtlanticHandler().preHandle(
|
||||
'https://theatlantic.com/article/'
|
||||
);
|
||||
|
||||
// We grab the title from the doucment.
|
||||
expect(response.dom?.querySelector('[data-event-module="article body"]')).toBeEmptyDOMElement()
|
||||
});
|
||||
|
||||
it ('should append a new div, and add the article content inside', () => {
|
||||
const response = await new TheAtlanticHandler().preHandle(
|
||||
'https://theatlantic.com/article/'
|
||||
);
|
||||
|
||||
// We grab the title from the doucment.
|
||||
expect(response.dom?.getElementById('prehandled')).not.toBeEmptyDOMElement()
|
||||
})
|
||||
})
|
||||
|
|
@ -14,7 +14,7 @@ const signToken = promisify(jwt.sign);
|
|||
const os = require('os');
|
||||
const { Storage } = require('@google-cloud/storage');
|
||||
const { parseHTML } = require('linkedom');
|
||||
const { preHandleContent, preParseContent } = require('../content-handler/src/index');
|
||||
const { preHandleContent, preParseContent } = require("@omnivore/content-handler");
|
||||
const { Readability } = require("@omnivore/readability");
|
||||
|
||||
const puppeteer = require('puppeteer-extra');
|
||||
|
|
|
|||
Loading…
Reference in a new issue