Skip to content

Commit 4067940

Browse files
committed
test(client-lex-runtime-service): add functional test
1 parent 6fd0a37 commit 4067940

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference types="mocha" />
2+
import { expect } from "chai";
3+
import { LexRuntimeService } from "./LexRuntimeService";
4+
import { SerializeMiddleware } from "@aws-sdk/types";
5+
import { HttpRequest } from "@aws-sdk/protocol-http";
6+
7+
describe("@aws-sdk/client-lex-runtime-service", () => {
8+
describe("PostContent", () => {
9+
it("should contain correct x-amz-content-sha256 header", async () => {
10+
const validator: SerializeMiddleware<any, any> = next => args => {
11+
// middleware intercept the request and return it early
12+
const request = args.request as HttpRequest;
13+
expect(request.headers).to.have.property(
14+
"x-amz-content-sha256",
15+
"UNSIGNED-PAYLOAD"
16+
);
17+
return Promise.resolve({ output: {} as any, response: {} as any });
18+
};
19+
const client = new LexRuntimeService({});
20+
client.middlewareStack.add(validator, {
21+
step: "serialize",
22+
name: "endpointValidator",
23+
priority: "low"
24+
});
25+
return await client.postContent({
26+
botAlias: "alias",
27+
botName: "bot",
28+
userId: "user",
29+
contentType: "text/plain; charset=utf-8",
30+
inputStream: "hello world!"
31+
});
32+
});
33+
});
34+
});

clients/client-lex-runtime-service/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"remove-documentation": "rimraf ./docs",
1313
"remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js",
1414
"remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map",
15-
"test": "exit 0",
15+
"test:unit": "mocha **/cjs/**/*.spec.js",
16+
"test": "yarn test:unit",
1617
"build:es": "tsc -p tsconfig.es.json",
1718
"build": "yarn pretest && yarn build:es"
1819
},
@@ -60,8 +61,9 @@
6061
"tslib": "^1.8.0"
6162
},
6263
"devDependencies": {
64+
"@types/chai": "^4.2.11",
65+
"@types/mocha": "^7.0.2",
6366
"@types/node": "^12.7.5",
64-
"jest": "^25.1.0",
6567
"rimraf": "^3.0.0",
6668
"tslib": "^1.8.0",
6769
"typedoc": "^0.15.0",

clients/client-lex-runtime-service/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"incremental": true,
1313
"resolveJsonModule": true,
1414
"declarationDir": "./types",
15-
"outDir": "dist/cjs"
15+
"outDir": "dist/cjs",
16+
"types": ["mocha", "node"]
1617
},
1718
"typedocOptions": {
1819
"exclude": "**/node_modules/**",

0 commit comments

Comments
 (0)