forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test coverage for most of Body-* swaggers (Azure#587)
* Add tests for BodyBoolean * Add coverage for BodyBooleanQuirks * Add coverage for bodyByte * Add coverage for BodyDate * Add coverage for BodyDateTime * Add coverage for DateTimeRfc1123 * Update core-http version * Add coverage for BodyDuration * Add coverage for BodyInteger * Add coverage for BodyNumber
- Loading branch information
Showing
120 changed files
with
8,353 additions
and
3 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
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,45 @@ | ||
import { BodyBooleanClient } from "./generated/bodyBoolean/src/bodyBooleanClient"; | ||
import { expect } from "chai"; | ||
describe("Bool Client", function() { | ||
let testClient: BodyBooleanClient; | ||
|
||
beforeEach(() => { | ||
testClient = new BodyBooleanClient(); | ||
}); | ||
|
||
it("should get true value", async () => { | ||
const { body } = await testClient.bool.getTrue(); | ||
expect(body).to.equal(true); | ||
}); | ||
|
||
it("should get false value", async () => { | ||
const { body } = await testClient.bool.getFalse(); | ||
expect(body).to.equal(false); | ||
}); | ||
|
||
it("should put true value", async () => { | ||
const result = await testClient.bool.putTrue(); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
|
||
it("should put false value", async () => { | ||
const result = await testClient.bool.putFalse(); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
|
||
it("should get null boolean value", async () => { | ||
const { body } = await testClient.bool.getNull(); | ||
expect(body).to.equal(undefined); | ||
}); | ||
|
||
it("should get invalid boolean value", async () => { | ||
let failed = false; | ||
try { | ||
await testClient.bool.getInvalid(); | ||
} catch (error) { | ||
failed = true; | ||
} finally { | ||
expect(failed).to.equal(true); | ||
} | ||
}); | ||
}); |
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,45 @@ | ||
import { BodyBooleanQuirksClient } from "./generated/bodyBooleanQuirks/src/bodyBooleanQuirksClient"; | ||
import { expect } from "chai"; | ||
describe("Bool Quirks Client", function() { | ||
let testClient: BodyBooleanQuirksClient; | ||
|
||
beforeEach(() => { | ||
testClient = new BodyBooleanQuirksClient(); | ||
}); | ||
|
||
it("should get true value", async () => { | ||
const { body } = await testClient.bool.getTrue(); | ||
expect(body).to.equal(true); | ||
}); | ||
|
||
it("should get false value", async () => { | ||
const { body } = await testClient.bool.getFalse(); | ||
expect(body).to.equal(false); | ||
}); | ||
|
||
it("should put true value", async () => { | ||
const result = await testClient.bool.putTrue(true); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
|
||
it("should put false value", async () => { | ||
const result = await testClient.bool.putFalse(false); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
|
||
it("should get null boolean value", async () => { | ||
const { body } = await testClient.bool.getNull(); | ||
expect(body).to.equal(undefined); | ||
}); | ||
|
||
it("should get invalid boolean value", async () => { | ||
let failed = false; | ||
try { | ||
await testClient.bool.getInvalid(); | ||
} catch (error) { | ||
failed = true; | ||
} finally { | ||
expect(failed).to.equal(true); | ||
} | ||
}); | ||
}); |
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,55 @@ | ||
import { BodyByteClient } from "./generated/bodyByte/src/bodyByteClient"; | ||
import { expect } from "chai"; | ||
describe("Bool Quirks Client", function() { | ||
let testClient: BodyByteClient; | ||
const testBytes = new Uint8Array([ | ||
255, | ||
254, | ||
253, | ||
252, | ||
251, | ||
250, | ||
249, | ||
248, | ||
247, | ||
246 | ||
]); | ||
|
||
beforeEach(() => { | ||
testClient = new BodyByteClient(); | ||
}); | ||
|
||
it("should get null value", async () => { | ||
const { body } = await testClient.byte.getNull(); | ||
expect(body).to.equal(undefined); | ||
}); | ||
|
||
it("should get empty value", async () => { | ||
const { body } = await testClient.byte.getEmpty(); | ||
expect(body).to.be.instanceOf(Uint8Array); | ||
expect(body.length).to.equal(0); | ||
}); | ||
|
||
it("should get non-ascii value", async () => { | ||
const { body } = await testClient.byte.getNonAscii(); | ||
expect(body.length).to.equal(testBytes.length); | ||
for (let i = 0; i < testBytes.length; i++) { | ||
expect(body[i]).to.equal(testBytes[i]); | ||
} | ||
}); | ||
|
||
it("should put non-ascii value", async () => { | ||
const result = await testClient.byte.putNonAscii(testBytes); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
|
||
it("should get invalid value", async () => { | ||
// Output of Buffer.from(':::SWAGGER::::', 'base64') | ||
const expected = new Uint8Array([73, 96, 6, 24, 68]); | ||
|
||
const { body } = await testClient.byte.getInvalid(); | ||
for (let i = 0; i < body.length; i++) { | ||
expect(body[i]).to.equal(expected[i]); | ||
} | ||
}); | ||
}); |
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,63 @@ | ||
import { BodyDateClient } from "./generated/bodyDate/src/bodyDateClient"; | ||
import { expect } from "chai"; | ||
describe("BodyDateClient", function() { | ||
let testClient: BodyDateClient; | ||
|
||
beforeEach(() => { | ||
testClient = new BodyDateClient(); | ||
}); | ||
|
||
it("should get min date", async () => { | ||
const { body: date } = await testClient.date.getMinDate(); | ||
expect(date.getUTCFullYear()).to.equal(1); | ||
expect(date.getUTCMonth()).to.equal(0); | ||
expect(date.getUTCDate()).to.equal(1); | ||
expect(date.getUTCHours()).to.equal(0); | ||
expect(date.getUTCMinutes()).to.equal(0); | ||
expect(date.getUTCSeconds()).to.equal(0); | ||
expect(date.getUTCMilliseconds()).to.equal(0); | ||
}); | ||
|
||
it("should get max date", async () => { | ||
const { body: date } = await testClient.date.getMaxDate(); | ||
expect(date.getUTCFullYear()).to.equal(9999); | ||
expect(date.getUTCMonth()).to.equal(11); | ||
expect(date.getUTCDate()).to.equal(31); | ||
expect(date.getUTCHours()).to.equal(0); | ||
expect(date.getUTCMinutes()).to.equal(0); | ||
expect(date.getUTCSeconds()).to.equal(0); | ||
expect(date.getUTCMilliseconds()).to.equal(0); | ||
}); | ||
|
||
it("should handle overflow date", async () => { | ||
const { body: date } = await testClient.date.getOverflowDate(); | ||
expect(isNaN(date.valueOf())).to.equal(true); | ||
}); | ||
|
||
it("should handle undeflow date", async () => { | ||
const { body: date } = await testClient.date.getUnderflowDate(); | ||
expect(isNaN(date.valueOf())).to.equal(true); | ||
}); | ||
|
||
it("should get a null value", async () => { | ||
const { body: date } = await testClient.date.getNull(); | ||
expect(date).to.equal(undefined); | ||
}); | ||
|
||
it("should get an invalid value", async () => { | ||
const { body: date } = await testClient.date.getInvalidDate(); | ||
expect(isNaN(date.valueOf())).to.equal(true); | ||
}); | ||
|
||
it("should put max date", async () => { | ||
const maxDate = new Date("9999-12-31"); | ||
const result = await testClient.date.putMaxDate(maxDate); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
|
||
it("should put min date", async () => { | ||
const minDate = new Date("0001-01-01"); | ||
const result = await testClient.date.putMinDate(minDate); | ||
expect(result._response.status).to.equal(200); | ||
}); | ||
}); |
Oops, something went wrong.