Skip to content

Commit c07767f

Browse files
committed
add test cases
1 parent 1386cdd commit c07767f

File tree

3 files changed

+80
-76
lines changed

3 files changed

+80
-76
lines changed

test/libs-channelAccessToken.spec.ts

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
1-
import {channelAccessToken} from "../lib";
1+
import { channelAccessToken } from "../lib";
22
import * as nock from "nock";
3-
import {deepEqual, equal} from "assert";
3+
import { deepEqual, equal } from "assert";
44

55
const pkg = require("../package.json");
66

77
const client = new channelAccessToken.ChannelAccessTokenClient({
8-
channelAccessToken: "test_channel_access_token",
8+
channelAccessToken: "test_channel_access_token",
99
});
1010

11-
1211
describe("channelAccessToken", () => {
13-
before(() => nock.disableNetConnect());
14-
afterEach(() => nock.cleanAll());
15-
after(() => nock.enableNetConnect());
12+
before(() => nock.disableNetConnect());
13+
afterEach(() => nock.cleanAll());
14+
after(() => nock.enableNetConnect());
1615

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, {});
16+
it("issueStatelessChannelToken", async () => {
17+
const scope = nock("https://api.line.me/", {
18+
reqheaders: {
19+
Authorization: "Bearer test_channel_access_token",
20+
"User-Agent": `${pkg.name}/${pkg.version}`,
21+
"content-type": "application/x-www-form-urlencoded",
22+
},
23+
})
24+
.post(
25+
"/oauth2/v3/token",
26+
"grantType=test_client_id&clientAssertionType=test_client_secret&clientAssertion=test_grant_type&clientId=test_redirect_uri&clientSecret=test_code",
27+
)
28+
.reply(200, {});
2729

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-
});
30+
const res = await client.issueStatelessChannelToken(
31+
"test_client_id",
32+
"test_client_secret",
33+
"test_grant_type",
34+
"test_redirect_uri",
35+
"test_code",
36+
);
37+
equal(scope.isDone(), true);
38+
deepEqual(res, {});
39+
});
3840
});

test/libs-manageAudience.spec.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
import {manageAudience} from "../lib";
1+
import { manageAudience } from "../lib";
22
import * as nock from "nock";
3-
import {deepEqual, equal} from "assert";
3+
import { deepEqual, equal } from "assert";
44

55
const pkg = require("../package.json");
66

77
const channelAccessToken = "test_channel_access_token";
88

99
const client = new manageAudience.ManageAudienceClient({
10-
channelAccessToken,
10+
channelAccessToken,
1111
});
1212

1313
const blobClient = new manageAudience.ManageAudienceBlobClient({
14-
channelAccessToken,
14+
channelAccessToken,
1515
});
1616

1717
describe("manageAudience", () => {
18-
before(() => nock.disableNetConnect());
19-
afterEach(() => nock.cleanAll());
20-
after(() => nock.enableNetConnect());
18+
before(() => nock.disableNetConnect());
19+
afterEach(() => nock.cleanAll());
20+
after(() => nock.enableNetConnect());
2121

22-
it("createAudienceForUploadingUserIds", 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": /^multipart\/form-data; boundary=.*$/,
28-
},
29-
})
30-
.post("/v2/bot/audienceGroup/upload/byFile", /.*boundary.*/)
31-
.reply(200, {});
22+
it("createAudienceForUploadingUserIds", 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": /^multipart\/form-data; boundary=.*$/,
28+
},
29+
})
30+
.post("/v2/bot/audienceGroup/upload/byFile", /.*boundary.*/)
31+
.reply(200, {});
3232

33-
const res = await blobClient.createAudienceForUploadingUserIds(
34-
new Blob(["c9161b19-57f8-46c2-a71f-dfa87314dabe"], {type: "text/plain"}),
35-
"test_description",
36-
true,
37-
);
38-
equal(scope.isDone(), true);
39-
deepEqual(res, {});
40-
});
33+
const res = await blobClient.createAudienceForUploadingUserIds(
34+
new Blob(["c9161b19-57f8-46c2-a71f-dfa87314dabe"], {
35+
type: "text/plain",
36+
}),
37+
"test_description",
38+
true,
39+
);
40+
equal(scope.isDone(), true);
41+
deepEqual(res, {});
42+
});
4143
});

test/libs-messagingApi.spec.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
import {messagingApi} from "../lib";
1+
import { messagingApi } from "../lib";
22
import * as nock from "nock";
3-
import {deepEqual, equal} from "assert";
3+
import { deepEqual, equal } from "assert";
44

55
const pkg = require("../package.json");
66

77
const channelAccessToken = "test_channel_access_token";
88

99
const client = new messagingApi.MessagingApiClient({
10-
channelAccessToken,
10+
channelAccessToken,
1111
});
1212

1313
const blobClient = new messagingApi.MessagingApiBlobClient({
14-
channelAccessToken,
14+
channelAccessToken,
1515
});
1616

1717
describe("messagingApi", () => {
18-
before(() => nock.disableNetConnect());
19-
afterEach(() => nock.cleanAll());
20-
after(() => nock.enableNetConnect());
18+
before(() => nock.disableNetConnect());
19+
afterEach(() => nock.cleanAll());
20+
after(() => nock.enableNetConnect());
2121

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, {});
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, {});
3232

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-
});
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+
});
4040
});

0 commit comments

Comments
 (0)