Skip to content

Commit

Permalink
[core-client] Add a test case for serializing a false body (#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 #14218.
  • Loading branch information
deyaaeldeen authored Mar 12, 2021
1 parent 6d578c1 commit f6ba5d9
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
Expand Up @@ -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(
Expand Down

0 comments on commit f6ba5d9

Please sign in to comment.