@@ -6,7 +6,7 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
6
6
7
7
describe ( 'when calling register with an valid batchInterval' , ( ) => {
8
8
const plugin = injectr ( '../index.js' , {
9
- 'fetch' : ( url , options ) => { }
9
+ request : sinon . stub ( ) . yields ( null , { } , 'ok' )
10
10
} ) ;
11
11
12
12
let error ;
@@ -24,7 +24,7 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
24
24
25
25
describe ( 'when calling register with no serverUrl' , ( ) => {
26
26
const plugin = injectr ( '../index.js' , {
27
- 'fetch' : ( url , options ) => { }
27
+ request : sinon . stub ( ) . yields ( null , { } , 'ok' )
28
28
} ) ;
29
29
let error ;
30
30
beforeEach ( ( done ) => {
@@ -41,7 +41,7 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
41
41
42
42
describe ( 'when calling with the correct options' , ( ) => {
43
43
const plugin = injectr ( '../index.js' , {
44
- 'fetch' : ( url , options ) => { }
44
+ request : sinon . stub ( ) . yields ( null , { } , 'ok' )
45
45
} ) ;
46
46
const next = sinon . spy ( ) ;
47
47
@@ -59,7 +59,7 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
59
59
60
60
describe ( 'when calling execute' , ( ) => {
61
61
const plugin = injectr ( '../index.js' , {
62
- 'fetch' : ( url , options ) => { }
62
+ request : sinon . stub ( ) . yields ( null , { } , 'ok' )
63
63
} ) ;
64
64
let client ;
65
65
beforeEach ( ( done ) => {
@@ -78,7 +78,7 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
78
78
describe ( 'when calling query and endpoint fails' , ( ) => {
79
79
let client ;
80
80
const plugin = injectr ( '../index.js' , {
81
- 'isomorphic-fetch' : sinon . stub ( ) . returns ( Promise . resolve ( { ok : false , statusText : 'Failure' } ) )
81
+ request : sinon . stub ( ) . yields ( null , { statusCode : 500 } , { } )
82
82
} ) ;
83
83
84
84
beforeEach ( ( done ) => {
@@ -92,15 +92,15 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
92
92
it ( 'should return a failure message' , ( done ) => {
93
93
client . query ( { query : { } , variables : { test : 1 } } , { 'accept-language' : 'en-US' } )
94
94
. catch ( error => {
95
- expect ( error . message ) . to . equal ( 'Failure ' )
95
+ expect ( error . message ) . to . equal ( 'Internal Server Error ' )
96
96
} ) . then ( done , done )
97
97
} ) ;
98
98
} ) ;
99
99
100
100
describe ( 'when calling query successfully' , ( ) => {
101
101
let client ;
102
102
const plugin = injectr ( '../index.js' , {
103
- 'isomorphic-fetch' : sinon . stub ( ) . returns ( Promise . resolve ( { ok : true , json : ( ) => Promise . resolve ( 'PASSED' ) } ) )
103
+ request : sinon . stub ( ) . yields ( null , { statusCode : 200 } , { someJson : true } )
104
104
} ) ;
105
105
106
106
beforeEach ( ( done ) => {
@@ -114,7 +114,7 @@ describe('OpenTable OC registry :: plugins :: graphql-plugin ', () => {
114
114
it ( 'should return a failture message' , ( done ) => {
115
115
client . query ( { query : { } , variables : { test : 1 } } , { 'accept-language' : 'en-US' } )
116
116
. then ( res => {
117
- expect ( res ) . to . equal ( 'PASSED' )
117
+ expect ( res ) . to . eql ( { someJson : true } )
118
118
} ) . then ( done , done )
119
119
} ) ;
120
120
} ) ;
0 commit comments