Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core-client] Add a test case for serializing a false body (Azure#14261)
Browse files Browse the repository at this point in the history
Adds a test case for a JSON body that is
- false
- null [according to the spec](https://www.json.org/json-en.html)

Those tests were missed in Azure#14218.
deyaaeldeen authored and vindicatesociety committed Apr 26, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 1940413 commit 426278f
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions sdk/core/core-client/test/serializationPolicy.spec.ts
Original file line number Diff line number Diff line change
@@ -44,6 +44,61 @@ describe("serializationPolicy", function() {
);
});

it("should serialize a JSON false request body", () => {
const httpRequest = createPipelineRequest({ url: "https://example.com" });
serializeRequestBody(
httpRequest,
{
boolBody: false
},
{
httpMethod: "PUT",
requestBody: {
parameterPath: "boolBody",
mapper: {
defaultValue: false,
isConstant: true,
serializedName: "boolBody",
type: {
name: "Boolean"
}
}
},
responses: { 200: {} },
serializer: createSerializer()
}
);
assert.strictEqual(httpRequest.body, `false`);
});

it("should serialize a JSON null request body", () => {
const httpRequest = createPipelineRequest({ url: "https://example.com" });
serializeRequestBody(
httpRequest,
{
boolBody: null
},
{
httpMethod: "PUT",
requestBody: {
parameterPath: "nullBody",
mapper: {
defaultValue: null,
isConstant: true,
serializedName: "nullBody",
nullable: true,
type: {
name: "String"
}
}
},
responses: { 200: {} },
serializer: createSerializer()
}
);
assert.strictEqual(httpRequest.body, `null`);
});

it("should serialize a JSON String request body", () => {
const httpRequest = createPipelineRequest({ url: "https://example.com" });
serializeRequestBody(

0 comments on commit 426278f

Please sign in to comment.