@@ -5,11 +5,11 @@ import graphqlWithSchema from '../schema';
5
5
describe ( 'hasMany' , function ( ) {
6
6
7
7
describe ( 'with a resolve function' , function ( ) {
8
- it ( 'passes a KnexJS query builder through to the resolve' , function * ( ) {
9
- yield clean ( ) ;
10
- var student = yield Student . forge ( { name : 'Joe Shmoe' } ) . save ( ) ;
11
- var classroom1 = yield student . classrooms ( ) . create ( ) ;
12
- var classroom2 = yield student . classrooms ( ) . create ( ) ;
8
+ it ( 'passes a KnexJS query builder through to the resolve' , async function ( ) {
9
+ await clean ( ) ;
10
+ var student = await Student . forge ( { name : 'Joe Shmoe' } ) . save ( ) ;
11
+ var classroom1 = await student . classrooms ( ) . create ( ) ;
12
+ var classroom2 = await student . classrooms ( ) . create ( ) ;
13
13
14
14
let query = `{
15
15
viewer(id: ${ student . get ( 'id' ) } ) {
@@ -19,7 +19,7 @@ describe('hasMany', function() {
19
19
}
20
20
}`
21
21
22
- const results = yield graphqlWithSchema ( query ) ;
22
+ const results = await graphqlWithSchema ( query ) ;
23
23
24
24
expect ( results ) . toEqual ( {
25
25
data : {
@@ -32,12 +32,12 @@ describe('hasMany', function() {
32
32
} ) ;
33
33
34
34
describe ( 'without a resolve function' , function ( ) {
35
- it ( 'returns bookshelf belongsToMany associated data' , function * ( ) {
36
- yield clean ( ) ;
37
- var student = yield Student . forge ( { name : 'Joe Shmoe' } ) . save ( ) ;
38
- var classroom1 = yield student . classrooms ( ) . create ( ) ;
39
- var classroom2 = yield student . classrooms ( ) . create ( ) ;
40
- var student2 = yield classroom2 . students ( ) . create ( { name : 'Marvin Martian' } ) ;
35
+ it ( 'returns bookshelf belongsToMany associated data' , async function ( ) {
36
+ await clean ( ) ;
37
+ var student = await Student . forge ( { name : 'Joe Shmoe' } ) . save ( ) ;
38
+ var classroom1 = await student . classrooms ( ) . create ( ) ;
39
+ var classroom2 = await student . classrooms ( ) . create ( ) ;
40
+ var student2 = await classroom2 . students ( ) . create ( { name : 'Marvin Martian' } ) ;
41
41
42
42
let query = `{
43
43
viewer(id: ${ student . get ( 'id' ) } ) {
@@ -47,7 +47,7 @@ describe('hasMany', function() {
47
47
}
48
48
}`
49
49
50
- const results = yield graphqlWithSchema ( query ) ;
50
+ const results = await graphqlWithSchema ( query ) ;
51
51
52
52
expect ( results ) . toEqual ( {
53
53
data : {
@@ -58,19 +58,20 @@ describe('hasMany', function() {
58
58
} ) ;
59
59
let { classrooms } = results . data . viewer ;
60
60
61
- expect ( classrooms ) . toContain ( { id : classroom1 . get ( 'id' ) } ) ;
62
- expect ( classrooms ) . toContain ( { id : classroom2 . get ( 'id' ) } ) ;
61
+ const stripped = classrooms . map ( ( { id} ) => id ) ;
62
+ expect ( stripped ) . toContain ( classroom1 . get ( 'id' ) ) ;
63
+ expect ( stripped ) . toContain ( classroom2 . get ( 'id' ) ) ;
63
64
} ) ;
64
-
65
+
65
66
} ) ;
66
-
67
+
67
68
describe ( 'with a relay connection type' , function ( ) {
68
- it ( 'returns a connection instead of an array' , function * ( ) {
69
- yield clean ( ) ;
70
- var student = yield Student . forge ( { name : 'Joe Shmoe' } ) . save ( ) ;
71
- var classroom = yield student . classrooms ( ) . create ( ) ;
72
- var homework1 = yield classroom . homeworks ( ) . create ( { content : 'I did it...' } ) ;
73
- var homework2 = yield classroom . homeworks ( ) . create ( { content : 'Look!!!' } ) ;
69
+ it ( 'returns a connection instead of an array' , async function ( ) {
70
+ await clean ( ) ;
71
+ var student = await Student . forge ( { name : 'Joe Shmoe' } ) . save ( ) ;
72
+ var classroom = await student . classrooms ( ) . create ( ) ;
73
+ var homework1 = await classroom . homeworks ( ) . create ( { content : 'I did it...' } ) ;
74
+ var homework2 = await classroom . homeworks ( ) . create ( { content : 'Look!!!' } ) ;
74
75
75
76
let query = `{
76
77
viewer(id: ${ student . get ( 'id' ) } ) {
@@ -86,7 +87,7 @@ describe('hasMany', function() {
86
87
}
87
88
}`
88
89
89
- const results = yield graphqlWithSchema ( query ) ;
90
+ const results = await graphqlWithSchema ( query ) ;
90
91
91
92
expect ( results ) . toEqual ( {
92
93
data : {
@@ -100,9 +101,9 @@ describe('hasMany', function() {
100
101
}
101
102
} ) ;
102
103
let { edges } = results . data . viewer . classrooms [ 0 ] . homeworks ;
103
-
104
- expect ( edges ) . toContain ( { node : { content : homework1 . get ( 'content' ) } } ) ;
105
- expect ( edges ) . toContain ( { node : { content : homework2 . get ( 'content' ) } } ) ;
104
+ const stripped = edges . map ( ( { node : { content } } ) => content ) ;
105
+ expect ( stripped ) . toContain ( homework1 . get ( 'content' ) ) ;
106
+ expect ( stripped ) . toContain ( homework2 . get ( 'content' ) ) ;
106
107
} ) ;
107
108
} ) ;
108
109
} ) ;
0 commit comments