Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #282 from donmahallem/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
donmahallem authored Feb 28, 2020
2 parents 163a856 + a03213f commit f605211
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 58 deletions.
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@donmahallem/trapeze-api-client",
"version": "4.0.0",
"version": "4.1.0",
"description": "Node Client to consume the Trapeze Api",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -25,23 +25,23 @@
"devDependencies": {
"@types/chai": "~4.2.9",
"@types/mocha": "~7.0.1",
"@types/node": "~13.7.4",
"@types/node": "~13.7.6",
"@types/request": "~2.48.4",
"@types/request-promise-native": "~1.0.17",
"@types/sinon": "~7.5.1",
"@types/sinon": "~7.5.2",
"chai": "~4.2.0",
"mocha": "~7.0.1",
"mocha": "~7.1.0",
"nock": "~12.0.1",
"nodemon": "~2.0.2",
"nyc": "~15.0.0",
"sinon": "~9.0.0",
"ts-node": "~8.6.2",
"tslint": "~6.0.0",
"typedoc": "~0.16.10",
"typedoc": "~0.16.11",
"typescript": "~3.8.2"
},
"peerDependencies": {
"@donmahallem/trapeze-api-types": ">=2.0.0"
"@donmahallem/trapeze-api-types": ">=2.2.0"
},
"nyc": {
"include": [
Expand Down
33 changes: 5 additions & 28 deletions src/trapeze-api-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import {
IStopLocations,
IStopPointInfo,
IStopPointLocations,
IVehicleLocationList,
} from '@donmahallem/trapeze-api-types';
Expand Down Expand Up @@ -115,24 +116,12 @@ describe('trapeze-api-client.ts', (): void => {
describe('api methods', (): void => {
describe('getStopPointInfo', (): void => {
['id1', 'id2'].forEach((testId: string): void => {
STOP_MODES.forEach((mode: StopMode): void => {
it('should query stop point info with mode: "' + mode + '" and id "' + testId + '"', (): Promise<void> => {
const scope: nock.Scope = nock(testDomain)
.post('/internetservice/services/stopInfo/stopPoint', 'mode=' + mode + '&stopPoint=' + testId)
.reply(200, testSuccessResponse);
return instance.getStopPointInfo(testId, mode)
.then((val: any): void => {
expect(val).to.deep.equal(testSuccessResponse);
expect(scope.isDone()).to.eq(true, 'scope should be done');
});
});
});
it('should query stop point info "' + testId + '" with default parameters', (): Promise<void> => {
it('should query stop point info with id "' + testId + '"', (): Promise<void> => {
const scope: nock.Scope = nock(testDomain)
.post('/internetservice/services/stopInfo/stopPoint', 'mode=departure&stopPoint=' + testId)
.post('/internetservice/services/stopInfo/stopPoint', 'stopPoint=' + testId)
.reply(200, testSuccessResponse);
return instance.getStopPointInfo(testId)
.then((val: any): void => {
.then((val: IStopPointInfo): void => {
expect(val).to.deep.equal(testSuccessResponse);
expect(scope.isDone()).to.eq(true, 'scope should be done');
});
Expand All @@ -141,21 +130,9 @@ describe('trapeze-api-client.ts', (): void => {
});
describe('getStopInfo', (): void => {
['id1', 'id2'].forEach((testId: string): void => {
STOP_MODES.forEach((mode: StopMode): void => {
it('should query stop info with mode: "' + mode + '" and id "' + testId + '"', (): Promise<void> => {
const scope: nock.Scope = nock(testDomain)
.post('/internetservice/services/stopInfo/stop', 'mode=' + mode + '&stop=' + testId)
.reply(200, testSuccessResponse);
return instance.getStopInfo(testId, mode)
.then((val: any): void => {
expect(val).to.deep.equal(testSuccessResponse);
expect(scope.isDone()).to.eq(true, 'scope should be done');
});
});
});
it('should query stop info "' + testId + '" with default parameters', (): Promise<void> => {
const scope: nock.Scope = nock(testDomain)
.post('/internetservice/services/stopInfo/stop', 'mode=departure&stop=' + testId)
.post('/internetservice/services/stopInfo/stop', 'stop=' + testId)
.reply(200, testSuccessResponse);
return instance.getStopInfo(testId)
.then((val: any): void => {
Expand Down
9 changes: 3 additions & 6 deletions src/trapeze-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
IStopInfo,
IStopLocations,
IStopPassage,
IStopPointInfo,
IStopPointLocations,
ITripPassages,
IVehicleLocationList,
Expand Down Expand Up @@ -253,11 +254,9 @@ export class TrapezeApiClient {
*
* @since 1.0.0
*/
public getStopInfo(stopId: StopId,
mode: StopMode = 'departure'): reqp.RequestPromise<IStopInfo> {
public getStopInfo(stopId: StopId): reqp.RequestPromise<IStopInfo> {
const options: req.OptionsWithUri = {
form: {
mode,
stop: stopId,
},
method: 'POST',
Expand All @@ -270,11 +269,9 @@ export class TrapezeApiClient {
*
* @since 1.0.0
*/
public getStopPointInfo(stopPointId: string,
mode: StopMode = 'departure'): reqp.RequestPromise<any> {
public getStopPointInfo(stopPointId: string): reqp.RequestPromise<IStopPointInfo> {
const options: req.OptionsWithUri = {
form: {
mode,
stopPoint: stopPointId,
},
method: 'POST',
Expand Down

0 comments on commit f605211

Please sign in to comment.