File tree Expand file tree Collapse file tree 1 file changed +43
-1
lines changed
Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,47 @@ import { Octokit } from "../src";
66const userAgent = `octokit-core.js/0.0.0-development ${ getUserAgent ( ) } ` ;
77
88describe ( "octokit.graphql()" , ( ) => {
9- it . todo ( "is a function" ) ;
9+ it ( "is a function" , ( ) => {
10+ const octokit = new Octokit ( ) ;
11+ expect ( octokit . graphql ) . toBeInstanceOf ( Function ) ;
12+ } ) ;
13+
14+ it ( "README usage example" , async ( ) => {
15+ const mockResult = {
16+ organization : {
17+ repositories : {
18+ totalCount : 123
19+ }
20+ }
21+ } ;
22+ const mock = fetchMock
23+ . sandbox ( )
24+ . postOnce ( "https://api.github.com/graphql" , ( url , request ) => {
25+ const body = JSON . parse ( request . body ! . toString ( ) ) ;
26+ expect ( body . query ) . toEqual ( query ) ;
27+
28+ return {
29+ data : mockResult
30+ } ;
31+ } ) ;
32+
33+ const octokit = new Octokit ( {
34+ auth : `secret123` ,
35+ request : {
36+ fetch : mock
37+ }
38+ } ) ;
39+
40+ const query = `query ($login: String!) {
41+ organization(login: $login) {
42+ repositories(privacy: PRIVATE) {
43+ totalCount
44+ }
45+ }
46+ }` ;
47+
48+ const result = await octokit . graphql ( query , { login : "octokit" } ) ;
49+
50+ expect ( result ) . toStrictEqual ( mockResult ) ;
51+ } ) ;
1052} ) ;
You can’t perform that action at this time.
0 commit comments