Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

guardian-js

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

guardian-js - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

src/Endpoint.js

7

package.json
{
"name": "guardian-js",
"version": "2.0.0",
"version": "3.0.0",
"description": "A JavaScript lib for the Guardian's api",

@@ -24,9 +24,8 @@ "main": "src/index.js",

"dependencies": {
"lodash": "^4.17.11",
"request": "^2.88.0"
},
"devDependencies": {
"expect": "^23.6.0",
"mocha": "^5.2.0"
"expect": "^25.3.0",
"mocha": "^7.1.1"
}
}

@@ -26,5 +26,5 @@ [![Build Status](https://travis-ci.org/PorterK/GuardianJSClient.svg?branch=master)](https://travis-ci.org/PorterK/GuardianJSClient)

```js
const Guardian = require('guardian-js');
import Guardian from 'guardian-js';
const api = new Guardian(apiKey, false);
const guardian = new Guardian(apiKey, false);
```

@@ -58,2 +58,10 @@

To get a single item you have to use `getById`
Ex:
```js
api.item.getById('business/2014/feb/18/uk-inflation-falls-below-bank-england-target');
```
### Note

@@ -60,0 +68,0 @@

'use strict';
let endpoints = require('./endpoints');
let Endpoint = require('./Endpoint').endpoint;
function Connect(key, secure){
this.content = new endpoints.content(key, secure);
this.tags = new endpoints.tags(key, secure);
this.sections = new endpoints.sections(key, secure);
this.editions = new endpoints.editions(key, secure);
this.item = new endpoints.item(key, secure);
this.custom = new endpoints.custom(key, secure);
this.content = new Endpoint('search', key, secure);
this.tags = new Endpoint('tags', key, secure);
this.sections = new Endpoint('sections', key, secure);
this.editions = new Endpoint('editions', key, secure);
this.item = new Endpoint(null, key, secure, ['getById']);
}

@@ -12,0 +11,0 @@

'use strict';
const expect = require('expect');
const guardian = require('../src');
const _ = require('lodash');
let api = new guardian('test', false);
let api = new guardian('2a896a41-f4fb-4dcd-829d-2034c043bb0d', false);
describe('Connection', function(){
it('should return OK', function(){
api.content.search()
.then(function(response){
expect(response.statusCode).toBe(200);
})
describe('Connection', () => {
it('should return OK', async () => {
const { response } = await api.content.search();
expect(response.statusCode).toBe(200);
})
});
describe('Content', function(){
it('has a search function that returns OK', function(){
api.content.search()
.then(function(response){
expect(response.statusCode).toBe(200);
});
describe('Content', async () => {
it('has a search function that returns OK', async () => {
const { response } = await api.content.search();
expect(response.statusCode).toBe(200);
});
it('properly parses filters', function(){
api.content.search('football', {
it('properly parses filters', async () => {
const { response } = await api.content.search('football', {
starRating: 3
})
.then(function(response){
expect(_.includes(response.req._header, 'star-rating'));
})
});
expect(response.req._header.includes('star-rating'));
});
it('actually returns content', function(){
api.content.search('football')
.then(function(r){
expect(JSON.parse(r.body).response.results.length).toBeGreaterThan(0);
})
it('actually returns content', async () => {
const response = await api.content.search('football');
expect(JSON.parse(response.body).response.results.length).toBeGreaterThan(0);
});

@@ -43,82 +38,64 @@

describe('Tags', function(){
it('has a search function that returns OK', function(){
api.tags.search()
.then(function(response){
expect(response.statusCode).toBe(200);
});
describe('Tags', () => {
it('has a search function that returns OK', async () => {
const { response } = await api.tags.search();
expect(response.statusCode).toBe(200);
});
it('properly parses filters', function(){
api.tags.search('football', {
it('properly parses filters', async () => {
const { response } = await api.tags.search('football', {
pageSize: 3
})
.then(function(response){
expect(_.includes(response.req._header, 'page-size'));
})
});
expect(response.req._header.includes('page-size'));
});
it('actually returns content', function(){
api.tags.search('sport')
.then(function(r){
expect(JSON.parse(r.body).response.results.length).toBeGreaterThan(0);
})
it('actually returns content', async () => {
const response = await api.tags.search('sport');
expect(JSON.parse(response.body).response.results.length).toBeGreaterThan(0);
});
});
describe('Sections', function(){
it('has a search function that returns OK', function(){
api.sections.search()
.then(function(response){
expect(response.statusCode).toBe(200);
});
describe('Sections', () => {
it('has a search function that returns OK', async () => {
const { response } = await api.sections.search();
expect(response.statusCode).toBe(200);
});
it('actually returns content', function(){
api.tags.search('world')
.then(function(r){
expect(JSON.parse(r.body).response.results.length).toBeGreaterThan(0);
})
it('actually returns content', async () => {
const { body } = await api.tags.search('world');
expect(JSON.parse(body).response.results.length).toBeGreaterThan(0);
});
});
describe('Editions', function(){
it('has a search function that returns OK', function(){
api.editions.search()
.then(function(response){
expect(response.statusCode).toBe(200);
});
describe('Editions', () => {
it('has a search function that returns OK', async () => {
const { response } = await api.editions.search();
expect(response.statusCode).toBe(200);
});
it('actually returns content', function(){
api.editions.search('u')
.then(function(r){
expect(JSON.parse(r.body).response.results.length).toBeGreaterThan(0);
})
it('actually returns content', async () => {
const { body } = await api.editions.search('u');
expect(JSON.parse(body).response.results.length).toBeGreaterThan(0);
});
});
describe('Item', function(){
it('has a search function that returns OK', function(){
api.item.search('football')
.then(function(response){
expect(response.statusCode).toBe(200);
});
describe('Item', () => {
it('has a search function that returns OK', async () => {
const { response } = await api.item.getById('business/2014/feb/18/uk-inflation-falls-below-bank-england-target');
expect(response.statusCode).toBe(200);
});
it('properly parses filters', function(){
api.item.search('football', {
starRating: 3
})
.then(function(response){
expect(_.includes(response.req._header, 'star-rating'));
})
});
it('actually returns content', async () => {
const { body } = await api.item.getById('business/2014/feb/18/uk-inflation-falls-below-bank-england-target');
it('actually returns content', function(){
api.item.search('world')
.then(function(r){
expect(JSON.parse(r.body).response.results.length).toBeGreaterThan(0);
})
expect(JSON.parse(body).response.total).toBeGreaterThan(0);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc