Skip to content

Commit

Permalink
Merge pull request #205 from jshemas/jan24
Browse files Browse the repository at this point in the history
updating tests/dependencies
  • Loading branch information
jshemas authored Jan 23, 2024
2 parents 98407ff + 5aff5b5 commit 0d39e11
Show file tree
Hide file tree
Showing 8 changed files with 519 additions and 352 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 6.3.3

- Updating dependencies
- Sent the `Accept: text/html` header by default

## 6.3.2

- Fixing issue with npm
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const fields = [
},
{
multiple: true,
property: 'og:video:url',
property: 'og:video:url', // An alternative to 'og:video'
fieldName: 'ogVideoProperty',
},
{
Expand Down
756 changes: 425 additions & 331 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"chardet": "^2.0.0",
"cheerio": "^1.0.0-rc.12",
"undici": "^5.26.4",
"undici": "^6.4.0",
"validator": "^13.11.0"
},
"files": [
Expand All @@ -36,24 +36,24 @@
"index.ts"
],
"devDependencies": {
"@snyk/protect": "^1.1236.0",
"@types/mocha": "^10.0.3",
"@snyk/protect": "^1.1272.0",
"@types/mocha": "^10.0.6",
"@types/node": "^18.18.3",
"@types/validator": "^13.11.5",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"chai": "^4.3.10",
"eslint": "^8.52.0",
"@types/validator": "^13.11.8",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"chai": "^4.4.1",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-mocha": "^10.2.0",
"eslint-plugin-promise": "^6.1.1",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"sinon": "^17.0.0",
"sinon": "^17.0.1",
"ts-mocha": "^10.0.0",
"typescript": "^5.2.2"
"typescript": "^5.3.3"
},
"repository": {
"type": "git",
Expand Down
54 changes: 53 additions & 1 deletion tests/integration/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,58 @@ describe('basic', function () {
expect(response).to.be.an('Response');
});
});
it('Test README.md using the default Accept: text/html header - Should Return correct Open Graph Info', function () {
return ogsRequire({ url: 'https://github.com/jshemas/openGraphScraper/blob/master/README.md' }).then(function ({ error, result, response }) {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.twitterSite).to.be.eql('@github');
expect(result.twitterCard).to.be.eql('summary_large_image');
expect(result.twitterTitle).to.be.eql('openGraphScraper/README.md at master · jshemas/openGraphScraper');
expect(result.twitterDescription).to.be.eql('Node.js scraper service for Open Graph Info and More! - jshemas/openGraphScraper');
expect(result.ogSiteName).to.be.eql('GitHub');
expect(result.ogType).to.be.eql('object');
expect(result.ogTitle).to.be.eql('openGraphScraper/README.md at master · jshemas/openGraphScraper');
expect(result.ogUrl).to.be.eql('https://github.com/jshemas/openGraphScraper/blob/master/README.md');
expect(result.ogDescription).to.be.eql('Node.js scraper service for Open Graph Info and More! - jshemas/openGraphScraper');
expect(result.ogImage).to.be.eql([
{
height: '600',
url: 'https://opengraph.githubassets.com/ffa796e90601a7e9f9c5221fd03c4d7d698e400f83a580c0d4a52b6844148f57/jshemas/openGraphScraper',
width: '1200',
},
]);
expect(result.twitterImage).to.be.eql([
{
url: 'https://opengraph.githubassets.com/ffa796e90601a7e9f9c5221fd03c4d7d698e400f83a580c0d4a52b6844148f57/jshemas/openGraphScraper',
},
]);
expect(result.ogLocale).to.be.eql('en');
expect(result.favicon).to.be.eql('https://github.githubassets.com/favicons/favicon.svg');
expect(result.charset).to.be.eql('utf-8');
expect(result.requestUrl).to.be.eql('https://github.com/jshemas/openGraphScraper/blob/master/README.md');
expect(result.success).to.be.eql(true);
expect(result).to.have.all.keys(
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogSiteName',
'ogTitle',
'ogType',
'ogUrl',
'requestUrl',
'success',
'twitterCard',
'twitterDescription',
'twitterImage',
'twitterSite',
'twitterTitle',
);
expect(response).to.be.an('Response');
});
});
it('vimeo.com should return open graph data', function () {
return ogsRequire({ url: 'https://vimeo.com/232889838' }).then(function ({ error, result, response }) {
console.log('error:', error);
Expand Down Expand Up @@ -302,7 +354,7 @@ describe('basic', function () {
// this is fail in the github CI since these tests can run any where
// expect(result.ogLocale).to.be.eql('en_US');
expect(result.ogImage).to.be.eql([{
url: 'https://www.facebook.com/images/fb_logo/app-facebook-circle-bp.png',
url: 'https://www.facebook.com/images/fb_icon_325x325.png',
type: 'png',
}]);
expect(result.ogTitle).to.be.eql('Facebook - log in or sign up');
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/blacklist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('blacklist', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.favicon).to.be.eql('/static/favicon/wikipedia.ico');
expect(result.ogLocale).to.be.eql('en');
Expand All @@ -47,8 +47,10 @@ describe('blacklist', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand All @@ -63,7 +65,7 @@ describe('blacklist', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.ogLocale).to.be.eql('en');
expect(result.requestUrl).to.be.eql('https://www.wikipedia.org/');
Expand All @@ -74,8 +76,10 @@ describe('blacklist', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/onlyGetOpenGraphInfo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('onlyGetOpenGraphInfo', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.ogLocale).to.be.eql('en');
expect(result.requestUrl).to.be.eql('http://www.wikipedia.org/');
Expand All @@ -43,8 +43,10 @@ describe('onlyGetOpenGraphInfo', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand Down
20 changes: 15 additions & 5 deletions tests/integration/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('url', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.ogLocale).to.be.eql('en');
expect(result.requestUrl).to.be.eql('http://www.wikipedia.org/');
Expand All @@ -19,8 +19,10 @@ describe('url', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand All @@ -32,7 +34,7 @@ describe('url', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.ogLocale).to.be.eql('en');
expect(result.requestUrl).to.be.eql('https://www.wikipedia.org/');
Expand All @@ -43,8 +45,10 @@ describe('url', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand All @@ -56,7 +60,7 @@ describe('url', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.ogLocale).to.be.eql('en');
expect(result.requestUrl).to.be.eql('http://www.wikipedia.org/');
Expand All @@ -67,8 +71,10 @@ describe('url', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand All @@ -80,7 +86,7 @@ describe('url', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.ogLocale).to.be.eql('en');
expect(result.requestUrl).to.be.eql('http://wikipedia.org/');
Expand All @@ -91,8 +97,10 @@ describe('url', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand All @@ -104,7 +112,7 @@ describe('url', function () {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be.eql(false);
expect(result.ogTitle).to.be.eql('Wikipedia');
expect(result.ogTitle).to.be.eql('Wikipedia, the free encyclopedia');
expect(result.ogLocale).to.be.eql('en');
expect(result.ogDescription).to.be.eql('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.requestUrl).to.be.eql('http://wikipedia.org/');
Expand All @@ -115,8 +123,10 @@ describe('url', function () {
'charset',
'favicon',
'ogDescription',
'ogImage',
'ogLocale',
'ogTitle',
'ogType',
'requestUrl',
'success',
);
Expand Down

0 comments on commit 0d39e11

Please sign in to comment.