Skip to content

Commit 1386cdd

Browse files
committed
channelAccessToken
1 parent 1c84c75 commit 1386cdd

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/libs-channelAccessToken.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {channelAccessToken} from "../lib";
2+
import * as nock from "nock";
3+
import {deepEqual, equal} from "assert";
4+
5+
const pkg = require("../package.json");
6+
7+
const client = new channelAccessToken.ChannelAccessTokenClient({
8+
channelAccessToken: "test_channel_access_token",
9+
});
10+
11+
12+
describe("channelAccessToken", () => {
13+
before(() => nock.disableNetConnect());
14+
afterEach(() => nock.cleanAll());
15+
after(() => nock.enableNetConnect());
16+
17+
it("issueStatelessChannelToken", async () => {
18+
const scope = nock("https://api.line.me/", {
19+
reqheaders: {
20+
Authorization: "Bearer test_channel_access_token",
21+
"User-Agent": `${pkg.name}/${pkg.version}`,
22+
"content-type": "application/x-www-form-urlencoded",
23+
},
24+
})
25+
.post("/oauth2/v3/token", "grantType=test_client_id&clientAssertionType=test_client_secret&clientAssertion=test_grant_type&clientId=test_redirect_uri&clientSecret=test_code")
26+
.reply(200, {});
27+
28+
const res = await client.issueStatelessChannelToken(
29+
"test_client_id",
30+
"test_client_secret",
31+
"test_grant_type",
32+
"test_redirect_uri",
33+
"test_code",
34+
);
35+
equal(scope.isDone(), true);
36+
deepEqual(res, {});
37+
});
38+
});

0 commit comments

Comments
 (0)