mirror of
https://github.com/holidayapi/holidayapi-node.git
synced 2025-06-21 04:26:33 +00:00
feat: pull country or language by code.
* feat: pull country or language by code. This differs from the existing `search` functionality in that it allows you to explicitly pull back a single country or language instead of anything that matches (which could result in more items returned than expected). * refactor(types): add new types for the affected endpoints. * docs(readme): update to include examples for new functionality. * test: expand tests to include new parameters. * feat(package): upgrade dependencies to the latest versions. * fix(eslint): adjust configuration based on an updated dependency. * docs(license): bump the year of the license.
This commit is contained in:
parent
9b40c4050e
commit
319d67d84b
10 changed files with 4543 additions and 1958 deletions
|
@ -93,6 +93,47 @@ describe('holidayapi', () => {
|
|||
expect(await holidayapi.countries()).toStrictEqual(expectedResponse);
|
||||
});
|
||||
|
||||
it('should return one country', async () => {
|
||||
const expectedResponse = {
|
||||
status: 200,
|
||||
requests: {
|
||||
used: 1000,
|
||||
available: 9000,
|
||||
resets: '2019-10-01 00:00:00',
|
||||
},
|
||||
countries: [
|
||||
{
|
||||
code: 'ST',
|
||||
name: 'Sao Tome and Principe',
|
||||
languages: ['pt'],
|
||||
codes: {
|
||||
'alpha-2': 'ST',
|
||||
'alpha-3': 'STP',
|
||||
numeric: 678,
|
||||
},
|
||||
flag: 'https://www.countryflags.io/ST/flat/64.png',
|
||||
subdivisions: [
|
||||
{
|
||||
code: 'ST-P',
|
||||
name: 'Príncipe',
|
||||
languages: ['pt'],
|
||||
},
|
||||
{
|
||||
code: 'ST-S',
|
||||
name: 'São Tomé',
|
||||
languages: ['pt'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
mockRequest.get(`${basePath}&country=ST`).reply(200, expectedResponse);
|
||||
expect(await holidayapi.countries({
|
||||
country: 'ST',
|
||||
})).toStrictEqual(expectedResponse);
|
||||
});
|
||||
|
||||
it('should search countries', async () => {
|
||||
const expectedResponse = {
|
||||
status: 200,
|
||||
|
@ -349,6 +390,28 @@ describe('holidayapi', () => {
|
|||
expect(await holidayapi.languages()).toStrictEqual(expectedResponse);
|
||||
});
|
||||
|
||||
it('should return one language', async () => {
|
||||
const expectedResponse = {
|
||||
status: 200,
|
||||
requests: {
|
||||
used: 1000,
|
||||
available: 9000,
|
||||
resets: '2019-10-01 00:00:00',
|
||||
},
|
||||
languages: [
|
||||
{
|
||||
code: 'hi',
|
||||
name: 'Hindi',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
mockRequest.get(`${basePath}&language=hi`).reply(200, expectedResponse);
|
||||
expect(await holidayapi.languages({
|
||||
language: 'hi',
|
||||
})).toStrictEqual(expectedResponse);
|
||||
});
|
||||
|
||||
it('should search languages', async () => {
|
||||
const expectedResponse = {
|
||||
status: 200,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue