Skip to content

Commit 93c1473

Browse files
committed
add test case for rich menu
1 parent e3532f3 commit 93c1473

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/libs-messagingApi.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {messagingApi} from "../lib";
2+
import * as nock from "nock";
3+
import {deepEqual, equal} from "assert";
4+
5+
const pkg = require("../package.json");
6+
7+
const channelAccessToken = "test_channel_access_token";
8+
9+
const client = new messagingApi.MessagingApiClient({
10+
channelAccessToken,
11+
});
12+
13+
const blobClient = new messagingApi.MessagingApiBlobClient({
14+
channelAccessToken,
15+
});
16+
17+
describe("messagingApi", () => {
18+
before(() => nock.disableNetConnect());
19+
afterEach(() => nock.cleanAll());
20+
after(() => nock.enableNetConnect());
21+
22+
it("setRichMenuImage", async () => {
23+
const scope = nock("https://api-data.line.me/", {
24+
reqheaders: {
25+
Authorization: "Bearer test_channel_access_token",
26+
"User-Agent": `${pkg.name}/${pkg.version}`,
27+
"content-type": "image/jpeg",
28+
},
29+
})
30+
.post("/v2/bot/richmenu/aaaaaa/content", "GREAT_JPEG")
31+
.reply(200, {});
32+
33+
const res = await blobClient.setRichMenuImage(
34+
"aaaaaa",
35+
new Blob(["GREAT_JPEG"], {type: "image/jpeg"}),
36+
);
37+
equal(scope.isDone(), true);
38+
deepEqual(res, {});
39+
});
40+
});

0 commit comments

Comments
 (0)