File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments