-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(:bug:): ensure that custom headers arent misidentified as request…
… parameters AFFECTS PACKAGES: @esri/arcgis-rest-request ISSUES CLOSED: #290
- Loading branch information
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/arcgis-rest-request/test/utils/append-params.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { appendCustomParams, IRequestOptions } from "../../src/index"; | ||
|
||
describe("appendCustomParams", () => { | ||
it("should not mis-identify standard request options as parameters.", () => { | ||
const oldOptions: any = { | ||
foo: "bar", | ||
headers: { | ||
Cookie: "monster" | ||
}, | ||
httpMethod: "GET", | ||
params: { baz: "luhrman" }, | ||
maxUrlLength: 1064 | ||
}; | ||
|
||
const newOptions: IRequestOptions = { | ||
params: {} | ||
}; | ||
|
||
appendCustomParams(oldOptions, newOptions); | ||
|
||
// all other request options should be mixed in outside this helper method | ||
expect(typeof newOptions.headers).toEqual("undefined"); | ||
expect(typeof newOptions.httpMethod).toEqual("undefined"); | ||
expect(typeof newOptions.maxUrlLength).toEqual("undefined"); | ||
expect(typeof newOptions.params.baz).toEqual("undefined"); | ||
|
||
expect(newOptions.params.foo).toEqual("bar"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters