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

holidayapi

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

holidayapi - npm Package Compare versions

Comparing version 4.2.0 to 5.0.0

10

package.json
{
"name": "holidayapi",
"version": "4.2.0",
"version": "5.0.0",
"description": "Official Node.js library for Holiday API",

@@ -24,3 +24,3 @@ "main": "dist/index.js",

"engines": {
"node": ">= 10.0.0"
"node": ">= 12.0.0"
},

@@ -30,3 +30,3 @@ "devDependencies": {

"@types/nock": "^11.1.0",
"@types/node": "^14.14.16",
"@types/node": "^15.12.2",
"@types/node-fetch": "^2.5.7",

@@ -39,5 +39,5 @@ "@typescript-eslint/eslint-plugin": "^4.11.1",

"eslint-plugin-jest": "^24.1.3",
"jest": "^26.6.3",
"jest": "^27.0.4",
"nock": "^13.0.5",
"ts-jest": "^26.4.4",
"ts-jest": "^27.0.3",
"typescript": "^4.1.3"

@@ -44,0 +44,0 @@ },

@@ -254,1 +254,13 @@ # Holiday API Node.js Library

```
### Workdays
#### Fetch number of workdays between two dates
```javascript
holidayApi.workday({
country: 'US',
start: '2019-07-01',
end: '2019-07-10',
});
```

@@ -610,3 +610,86 @@ import * as nock from 'nock';

});
describe('/v1/workdays', () => {
const basePath = `/workdays?key=${key}`;
it('should return workdays', async () => {
const expectedResponse = {
status: 200,
requests: {
used: 1000,
available: 9000,
resets: '2019-10-01 00:00:00',
},
workdays: 7,
};
mockRequest.get(`${basePath}&country=US&start=2019-07-01&end=2019-07-10`)
.reply(200, expectedResponse);
expect(await holidayapi.workdays({
country: 'US',
start: '2019-07-01',
end: '2019-07-10',
})).toStrictEqual(expectedResponse);
});
it('should error when country is missing', async () => {
expect.assertions(1);
try {
await holidayapi.workdays();
} catch (err) {
expect(err.message).toMatch(/missing country/i);
}
});
it('should error when start is missing', async () => {
expect.assertions(1);
try {
await holidayapi.workdays({ country: 'US' });
} catch (err) {
expect(err.message).toMatch(/missing start date/i);
}
});
it('should error when end is missing', async () => {
expect.assertions(1);
try {
await holidayapi.workdays({ country: 'US', start: '2019-07-01' });
} catch (err) {
expect(err.message).toMatch(/missing end date/i);
}
});
it('should raise 4xx errors', async () => {
const expectedResponse = {
status: 429,
error: 'Rate limit exceeded',
};
expect.assertions(1);
mockRequest.get(`${basePath}&country=US&start=2019-07-01&end=2019-07-10`)
.reply(429, expectedResponse);
try {
await holidayapi.workdays({ country: 'US', start: '2019-07-01', end: '2019-07-10' });
} catch (err) {
expect(err.message).toMatch(/rate limit exceeded/i);
}
});
it('should raise 5xx errors', async () => {
expect.assertions(1);
mockRequest.get(`${basePath}&country=US&start=2019-07-01&end=2019-07-10`).reply(500);
try {
await holidayapi.workdays({ country: 'US', start: '2019-07-01', end: '2019-07-10' });
} catch (err) {
expect(err.message).toMatch(/internal server error/i);
}
});
});
});
});

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