Skip to content

Commit

Permalink
update deprecated xxx.connect() with new xxx()
Browse files Browse the repository at this point in the history
- no more deprecated connect method  in test files
  • Loading branch information
Cojad committed Mar 20, 2022
1 parent d6024e2 commit c7944da
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('connect', () => {
},
},
});
LineClient.connect({
// eslint-disable-next-line no-new
new LineClient({
accessToken: ACCESS_TOKEN,
channelSecret: CHANNEL_SECRET,
});
Expand All @@ -49,7 +50,8 @@ describe('connect', () => {
},
},
});
LineClient.connect({
// eslint-disable-next-line no-new
new LineClient({
accessToken: ACCESS_TOKEN,
channelSecret: CHANNEL_SECRET,
origin: 'https://mydummytestserver.com',
Expand Down
3 changes: 2 additions & 1 deletion packages/messaging-api-line/src/__tests__/LineNotify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ describe('connect', () => {

it('create axios with LINE Notify API', () => {
axios.create = jest.fn();
LineNotify.connect({
// eslint-disable-next-line no-new
new LineNotify({
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
redirectUri: REDIRECT_URI,
Expand Down
3 changes: 2 additions & 1 deletion packages/messaging-api-line/src/__tests__/LinePay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe('connect', () => {

it('create axios with LINE PAY API', () => {
axios.create = jest.fn();
LinePay.connect({
// eslint-disable-next-line no-new
new LinePay({
channelId: CHANNEL_ID,
channelSecret: CHANNEL_SECRET,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('connect', () => {
},
},
});
MessengerClient.connect({ accessToken: ACCESS_TOKEN });
// eslint-disable-next-line no-new
new MessengerClient({ accessToken: ACCESS_TOKEN });

expect(axios.create).toBeCalledWith(
expect.objectContaining({
Expand All @@ -46,7 +47,8 @@ describe('connect', () => {
},
},
});
MessengerClient.connect({ accessToken: ACCESS_TOKEN, version: '2.6' });
// eslint-disable-next-line no-new
new MessengerClient({ accessToken: ACCESS_TOKEN, version: '2.6' });

expect(axios.create).toBeCalledWith(
expect.objectContaining({
Expand All @@ -65,7 +67,8 @@ describe('connect', () => {
},
},
});
MessengerClient.connect({
// eslint-disable-next-line no-new
new MessengerClient({
accessToken: ACCESS_TOKEN,
origin: 'https://mydummytestserver.com',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('connect', () => {
},
},
});
SlackOAuthClient.connect({ accessToken: TOKEN });
// eslint-disable-next-line no-new
new SlackOAuthClient({ accessToken: TOKEN });

expect(axios.create).toBeCalledWith({
baseURL: 'https://slack.com/api/',
Expand All @@ -42,7 +43,8 @@ describe('connect', () => {
},
},
});
SlackOAuthClient.connect({
// eslint-disable-next-line no-new
new SlackOAuthClient({
accessToken: TOKEN,
origin: 'https://mydummytestserver.com',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('connect', () => {
},
},
});
SlackWebhookClient.connect({ url: URL });
// eslint-disable-next-line no-new
new SlackWebhookClient({ url: URL });

expect(axios.create).toBeCalledWith({
baseURL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ describe('connect', () => {
},
},
});
TelegramClient.connect({ accessToken: ACCESS_TOKEN });
// eslint-disable-next-line no-new
new TelegramClient({ accessToken: ACCESS_TOKEN });

expect(axios.create).toBeCalledWith({
baseURL:
Expand All @@ -53,7 +54,8 @@ describe('connect', () => {
},
},
});
TelegramClient.connect({
// eslint-disable-next-line no-new
new TelegramClient({
accessToken: ACCESS_TOKEN,
origin: 'https://mydummytestserver.com',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,14 @@ describe('other api', () => {
from_chat_id: 313534466,
message_id: 203,
disable_notification: true,
protect_content: true,
})
.reply(200, reply);

const res = await client.forwardMessage(427770117, 313534466, 203, {
// @ts-expect-error
disable_notification: true,
protect_content: true,
});

expect(res).toEqual(result);
Expand All @@ -833,11 +835,13 @@ describe('other api', () => {
from_chat_id: 313534466,
message_id: 203,
disable_notification: true,
protect_content: true,
})
.reply(200, reply);

const res = await client.forwardMessage(427770117, 313534466, 203, {
disableNotification: true,
protectContent: true,
});

expect(res).toEqual(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ describe('connect', () => {
},
},
});
ViberClient.connect({ accessToken: AUTH_TOKEN, sender: SENDER });
// eslint-disable-next-line no-new
new ViberClient({ accessToken: AUTH_TOKEN, sender: SENDER });

expect(axios.create).toBeCalledWith({
baseURL: 'https://chatapi.viber.com/pa/',
Expand All @@ -50,7 +51,8 @@ describe('connect', () => {
},
},
});
ViberClient.connect({
// eslint-disable-next-line no-new
new ViberClient({
accessToken: AUTH_TOKEN,
sender: SENDER,
origin: 'https://mydummytestserver.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('connect', () => {
},
},
});
WechatClient.connect({ appId: APP_ID, appSecret: APP_SECRET });
// eslint-disable-next-line no-new
new WechatClient({ appId: APP_ID, appSecret: APP_SECRET });

expect(axios.create).toBeCalledWith({
baseURL: 'https://api.weixin.qq.com/cgi-bin/',
Expand All @@ -45,7 +46,8 @@ describe('connect', () => {
},
},
});
WechatClient.connect({
// eslint-disable-next-line no-new
new WechatClient({
appId: APP_ID,
appSecret: APP_SECRET,
origin: 'https://mydummytestserver.com',
Expand Down

0 comments on commit c7944da

Please sign in to comment.