-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
45 additions
and
17 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
packages/metascraper-clearbit-logo/__snapshots__/index.js.snap-shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
exports['if logo is not present, fallback to clearbit logo API 1'] = { | ||
"author": null, | ||
"date": null, | ||
"description": null, | ||
"image": null, | ||
"logo": "https://logo.clearbit.com/facebook.com?size=128&format=png", | ||
"publisher": null, | ||
"title": null, | ||
"url": "https://facebook.com" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"rules": [ | ||
"metascraper-author", | ||
"metascraper-date", | ||
"metascraper-description", | ||
"metascraper-image", | ||
"metascraper-logo", | ||
"metascraper-clearbit-logo", | ||
"metascraper-publisher", | ||
"metascraper-title", | ||
"metascraper-url" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
'use strict' | ||
|
||
const should = require('should') | ||
|
||
const clearbit = require('..')() | ||
const clearModule = require('clear-module') | ||
const snapshot = require('snap-shot') | ||
|
||
describe('metascraper clearbit logo', () => { | ||
it('if logo is present, not do nothing', () => { | ||
const url = 'https://facebook.com' | ||
const meta = { logo: 'https://facebook.com/logo.png' } | ||
const data = clearbit.logo({ url, meta }) | ||
should(data).be.undefined() | ||
before(() => { | ||
clearModule.all() | ||
process.env.METASCRAPER_CONFIG_CWD = __dirname | ||
}) | ||
|
||
after(() => { | ||
clearModule.all() | ||
delete process.env.METASCRAPER_CONFIG_CWD | ||
}) | ||
|
||
it('if logo is not present, fallback to clearbit logo API', () => { | ||
it('if logo is not present, fallback to clearbit logo API', async () => { | ||
const metascraper = require('metascraper') | ||
const url = 'https://facebook.com' | ||
const meta = { logo: 'https://facebook.com/favicon.ico' } | ||
const data = clearbit.logo({ url, meta }) | ||
should(data).be.equal( | ||
'https://logo.clearbit.com/facebook.com?size=128&format=png' | ||
) | ||
const html = '<div></div>' | ||
const meta = await metascraper({ html, url }) | ||
snapshot(meta) | ||
}) | ||
}) |