1
- import { run } from '../api/server' ;
2
1
import rp from 'request-promise' ;
2
+ import casual from 'casual' ;
3
+
4
+ import { run } from '../api/server' ;
3
5
4
6
const testPort = 6789 ;
5
7
const endpointUrl = `http://localhost:${ testPort } /graphql` ;
@@ -10,6 +12,56 @@ beforeAll(() => {
10
12
} ) ;
11
13
12
14
it ( 'accepts a query' , async ( ) => {
15
+ casual . seed ( 123 ) ;
16
+
17
+ [
18
+ [ 'apollographql/apollo-client' , 'stubailo' ] ,
19
+ [ 'apollographql/graphql-server' , 'helfer' ] ,
20
+ [ 'meteor/meteor' , 'tmeasday' ] ,
21
+ [ 'twbs/bootstrap' , 'Slava' ] ,
22
+ [ 'd3/d3' , 'Slava' ] ,
23
+ ] . forEach ( ( [ full_name , postedBy ] ) => {
24
+ // First, it will request the repository;
25
+ rp . __pushMockRequest ( {
26
+ options : {
27
+ uri : `/repos/${ full_name } ` ,
28
+ } ,
29
+ result : {
30
+ headers : {
31
+ etag : casual . string ,
32
+ } ,
33
+ body : {
34
+ name : full_name . split ( '/' ) [ 1 ] ,
35
+ full_name,
36
+ description : casual . sentence ,
37
+ html_url : casual . url ,
38
+ stargazers_count : casual . integer ( 0 ) ,
39
+ open_issues_count : casual . integer ( 0 ) ,
40
+ owner : {
41
+ login : full_name . split ( '/' ) [ 0 ] ,
42
+ avatar_url : casual . url ,
43
+ html_url : casual . url ,
44
+ } ,
45
+ } ,
46
+ } ,
47
+ } ) ;
48
+
49
+ // Then the user who posted it
50
+ rp . __pushMockRequest ( {
51
+ options : {
52
+ uri : `/users/${ postedBy } ` ,
53
+ } ,
54
+ result : {
55
+ headers : {
56
+ etag : casual . string ,
57
+ } ,
58
+ body : {
59
+ login : postedBy ,
60
+ } ,
61
+ } ,
62
+ } ) ;
63
+ } ) ;
64
+
13
65
const result = await fetchGraphQL ( `
14
66
{
15
67
feed (type: NEW, limit: 5) {
@@ -32,7 +84,7 @@ afterAll(() => {
32
84
} ) ;
33
85
34
86
function fetchGraphQL ( query , variables ) {
35
- return rp ( endpointUrl , {
87
+ return rp . actual ( endpointUrl , {
36
88
method : 'post' ,
37
89
body : { query, variables } ,
38
90
json : true ,
0 commit comments