1- const plugin = require ( "./fetch-repos" ) ;
2- const { Octokit } = require ( "@octokit/rest" ) ;
1+ import plugin from "./fetch-repos" ;
2+ import { Octokit } from "@octokit/rest" ;
3+ import nock from "nock" ;
34
4- const nock = require ( "nock" ) ;
55nock . disableNetConnect ( ) ;
6- const octokit = new Octokit ( ) ;
6+ const octokit = new Octokit ( {
7+ log : {
8+ error : ( ) => { } ,
9+ } ,
10+ } ) ;
711
812function run ( body ) {
913 return plugin ( octokit , body ) ;
@@ -18,7 +22,7 @@ test(`owner does not exist`, async () => {
1822 mockGetUser ( owner , null ) ;
1923
2024 await expect ( run ( { owner } ) ) . rejects . toEqual (
21- `The user/org '${ owner } ' could not be found`
25+ `The user/org '${ owner } ' could not be found` ,
2226 ) ;
2327} ) ;
2428
@@ -27,7 +31,7 @@ test(`team requested, but user is not an org`, async () => {
2731 mockGetUser ( "valid-user" , "User" ) ;
2832
2933 await expect ( run ( { owner } ) ) . rejects . toEqual (
30- `The provided 'owner' is not an organization, and so can not have teams`
34+ `The provided 'owner' is not an organization, and so can not have teams` ,
3135 ) ;
3236} ) ;
3337
@@ -76,7 +80,7 @@ test(`runs with defaults`, async () => {
7680 await expect (
7781 run ( {
7882 owner : "mheap" ,
79- } )
83+ } ) ,
8084 ) . resolves . toEqual ( [
8185 publicRepo ,
8286 privateRepo ,
@@ -94,7 +98,7 @@ test(`can disable forks`, async () => {
9498 run ( {
9599 owner : "mheap" ,
96100 include_forks : false ,
97- } )
101+ } ) ,
98102 ) . resolves . toEqual ( [ ] ) ;
99103} ) ;
100104
@@ -105,7 +109,7 @@ test(`allows archived`, async () => {
105109 run ( {
106110 owner : "mheap" ,
107111 include_archived : true ,
108- } )
112+ } ) ,
109113 ) . resolves . toEqual ( [ archivedRepo ] ) ;
110114} ) ;
111115
@@ -116,7 +120,7 @@ test(`allows templates`, async () => {
116120 run ( {
117121 owner : "mheap" ,
118122 include_templates : true ,
119- } )
123+ } ) ,
120124 ) . resolves . toEqual ( [ templateRepo ] ) ;
121125} ) ;
122126
@@ -127,7 +131,7 @@ test(`filters to only public`, async () => {
127131 run ( {
128132 owner : "mheap" ,
129133 visibility : "public" ,
130- } )
134+ } ) ,
131135 ) . resolves . toEqual ( [ publicRepo ] ) ;
132136} ) ;
133137
@@ -138,7 +142,7 @@ test(`filters to only private`, async () => {
138142 run ( {
139143 owner : "mheap" ,
140144 visibility : "private" ,
141- } )
145+ } ) ,
142146 ) . resolves . toEqual ( [ privateRepo ] ) ;
143147} ) ;
144148
@@ -149,7 +153,7 @@ test(`permissions: pull (success)`, async () => {
149153 run ( {
150154 owner : "mheap" ,
151155 minimum_access : "pull" ,
152- } )
156+ } ) ,
153157 ) . resolves . toEqual ( [ repoWithPull ] ) ;
154158} ) ;
155159
@@ -160,7 +164,7 @@ test(`permissions: push (success)`, async () => {
160164 run ( {
161165 owner : "mheap" ,
162166 minimum_access : "push" ,
163- } )
167+ } ) ,
164168 ) . resolves . toEqual ( [ repoWithPush ] ) ;
165169} ) ;
166170
@@ -171,7 +175,7 @@ test(`permissions: pull (success)`, async () => {
171175 run ( {
172176 owner : "mheap" ,
173177 minimum_access : "admin" ,
174- } )
178+ } ) ,
175179 ) . resolves . toEqual ( [ repoWithAdmin ] ) ;
176180} ) ;
177181
@@ -182,7 +186,7 @@ test(`permissions: pull (no auth, implicitly allowed)`, async () => {
182186 run ( {
183187 owner : "mheap" ,
184188 minimum_access : "pull" ,
185- } )
189+ } ) ,
186190 ) . resolves . toEqual ( [ publicRepo ] ) ;
187191} ) ;
188192
@@ -193,7 +197,7 @@ test(`permissions: pull (no auth, implicitly disallowed)`, async () => {
193197 run ( {
194198 owner : "mheap" ,
195199 minimum_access : "push" ,
196- } )
200+ } ) ,
197201 ) . resolves . toEqual ( [ ] ) ;
198202} ) ;
199203
@@ -204,7 +208,7 @@ test(`permissions: push (failure)`, async () => {
204208 run ( {
205209 owner : "mheap" ,
206210 minimum_access : "push" ,
207- } )
211+ } ) ,
208212 ) . resolves . toEqual ( [ ] ) ;
209213} ) ;
210214
@@ -215,7 +219,7 @@ test(`permissions: admin (failure)`, async () => {
215219 run ( {
216220 owner : "mheap" ,
217221 minimum_access : "admin" ,
218- } )
222+ } ) ,
219223 ) . resolves . toEqual ( [ ] ) ;
220224} ) ;
221225
@@ -226,7 +230,7 @@ test(`permissions: minimum_access is case insensitive`, async () => {
226230 run ( {
227231 owner : "mheap" ,
228232 minimum_access : "ADMIN" ,
229- } )
233+ } ) ,
230234 ) . resolves . toEqual ( [ repoWithAdmin ] ) ;
231235} ) ;
232236
@@ -254,7 +258,7 @@ function mockGetOrgRepos(owner, repos) {
254258
255259function mockGetTeamRepos ( owner , team_slug , repos ) {
256260 const m = nock ( "https://api.github.com" ) . get (
257- `/orgs/${ owner } /teams/${ team_slug } /repos`
261+ `/orgs/${ owner } /teams/${ team_slug } /repos` ,
258262 ) ;
259263 return m . reply ( 200 , repos ) ;
260264}
0 commit comments