@@ -8,26 +8,28 @@ describe('callAsyncFunction', () => {
88 expect ( result ) . toEqual ( 'bar' )
99 } )
1010
11- test ( 'passes getOctokit through the script context' , async ( ) => {
12- const getOctokit = jest . fn ( ) . mockReturnValue ( 'secondary-client' )
11+ test ( 'passes createOctokit through the script context' , async ( ) => {
12+ const createOctokit = jest . fn ( ) . mockReturnValue ( 'secondary-client' )
1313
1414 const result = await callAsyncFunction (
15- { getOctokit } as any ,
16- "return getOctokit ('token')"
15+ { createOctokit } as any ,
16+ "return createOctokit ('token')"
1717 )
1818
19- expect ( getOctokit ) . toHaveBeenCalledWith ( 'token' )
19+ expect ( createOctokit ) . toHaveBeenCalledWith ( 'token' )
2020 expect ( result ) . toEqual ( 'secondary-client' )
2121 } )
2222
23- test ( 'getOctokit creates client independent from github' , async ( ) => {
23+ test ( 'createOctokit creates client independent from github' , async ( ) => {
2424 const github = { rest : { issues : 'primary' } }
25- const getOctokit = jest . fn ( ) . mockReturnValue ( { rest : { issues : 'secondary' } } )
25+ const createOctokit = jest
26+ . fn ( )
27+ . mockReturnValue ( { rest : { issues : 'secondary' } } )
2628
2729 const result = await callAsyncFunction (
28- { github, getOctokit } as any ,
30+ { github, createOctokit } as any ,
2931 `
30- const secondary = getOctokit ('other-token')
32+ const secondary = createOctokit ('other-token')
3133 return {
3234 primary: github.rest.issues,
3335 secondary: secondary.rest.issues,
@@ -41,32 +43,32 @@ describe('callAsyncFunction', () => {
4143 secondary : 'secondary' ,
4244 different : true
4345 } )
44- expect ( getOctokit ) . toHaveBeenCalledWith ( 'other-token' )
46+ expect ( createOctokit ) . toHaveBeenCalledWith ( 'other-token' )
4547 } )
4648
47- test ( 'getOctokit passes options through' , async ( ) => {
48- const getOctokit = jest . fn ( ) . mockReturnValue ( 'client-with-opts' )
49+ test ( 'createOctokit passes options through' , async ( ) => {
50+ const createOctokit = jest . fn ( ) . mockReturnValue ( 'client-with-opts' )
4951
5052 const result = await callAsyncFunction (
51- { getOctokit } as any ,
52- `return getOctokit ('my-token', { baseUrl: 'https://ghes.example.com/api/v3' })`
53+ { createOctokit } as any ,
54+ `return createOctokit ('my-token', { baseUrl: 'https://ghes.example.com/api/v3' })`
5355 )
5456
55- expect ( getOctokit ) . toHaveBeenCalledWith ( 'my-token' , {
57+ expect ( createOctokit ) . toHaveBeenCalledWith ( 'my-token' , {
5658 baseUrl : 'https://ghes.example.com/api/v3'
5759 } )
5860 expect ( result ) . toEqual ( 'client-with-opts' )
5961 } )
6062
61- test ( 'getOctokit supports plugins' , async ( ) => {
62- const getOctokit = jest . fn ( ) . mockReturnValue ( 'client-with-plugins' )
63+ test ( 'createOctokit supports plugins' , async ( ) => {
64+ const createOctokit = jest . fn ( ) . mockReturnValue ( 'client-with-plugins' )
6365
6466 const result = await callAsyncFunction (
65- { getOctokit } as any ,
66- `return getOctokit ('my-token', { previews: ['v3'] }, 'pluginA', 'pluginB')`
67+ { createOctokit } as any ,
68+ `return createOctokit ('my-token', { previews: ['v3'] }, 'pluginA', 'pluginB')`
6769 )
6870
69- expect ( getOctokit ) . toHaveBeenCalledWith (
71+ expect ( createOctokit ) . toHaveBeenCalledWith (
7072 'my-token' ,
7173 { previews : [ 'v3' ] } ,
7274 'pluginA' ,
@@ -75,24 +77,24 @@ describe('callAsyncFunction', () => {
7577 expect ( result ) . toEqual ( 'client-with-plugins' )
7678 } )
7779
78- test ( 'multiple getOctokit calls produce independent clients' , async ( ) => {
79- const getOctokit = jest
80+ test ( 'multiple createOctokit calls produce independent clients' , async ( ) => {
81+ const createOctokit = jest
8082 . fn ( )
8183 . mockReturnValueOnce ( { id : 'client-a' } )
8284 . mockReturnValueOnce ( { id : 'client-b' } )
8385
8486 const result = await callAsyncFunction (
85- { getOctokit } as any ,
87+ { createOctokit } as any ,
8688 `
87- const a = getOctokit ('token-a')
88- const b = getOctokit ('token-b')
89+ const a = createOctokit ('token-a')
90+ const b = createOctokit ('token-b')
8991 return { a: a.id, b: b.id, different: a !== b }
9092 `
9193 )
9294
93- expect ( getOctokit ) . toHaveBeenCalledTimes ( 2 )
94- expect ( getOctokit ) . toHaveBeenNthCalledWith ( 1 , 'token-a' )
95- expect ( getOctokit ) . toHaveBeenNthCalledWith ( 2 , 'token-b' )
95+ expect ( createOctokit ) . toHaveBeenCalledTimes ( 2 )
96+ expect ( createOctokit ) . toHaveBeenNthCalledWith ( 1 , 'token-a' )
97+ expect ( createOctokit ) . toHaveBeenNthCalledWith ( 2 , 'token-b' )
9698 expect ( result ) . toEqual ( { a : 'client-a' , b : 'client-b' , different : true } )
9799 } )
98100
0 commit comments