@@ -50,7 +50,7 @@ describe('GithubTeams', () => {
50
50
51
51
52
52
it ( 'should return a promise' , ( ) => {
53
- githubApi . get . and . returnValue ( Promise . resolve ( ) ) ;
53
+ githubApi . get . and . callFake ( ( ) => Promise . resolve ( ) ) ;
54
54
const promise = teams . isMemberById ( 'user' , [ 1 ] ) ;
55
55
expect ( promise ) . toEqual ( jasmine . any ( Promise ) ) ;
56
56
} ) ;
@@ -66,7 +66,7 @@ describe('GithubTeams', () => {
66
66
67
67
68
68
it ( 'should call \'get()\' with the correct pathname' , done => {
69
- githubApi . get . and . returnValue ( Promise . resolve ( ) ) ;
69
+ githubApi . get . and . callFake ( ( ) => Promise . resolve ( ) ) ;
70
70
teams . isMemberById ( 'user' , [ 1 ] ) . then ( ( ) => {
71
71
expect ( githubApi . get ) . toHaveBeenCalledWith ( '/teams/1/memberships/user' ) ;
72
72
done ( ) ;
@@ -75,7 +75,7 @@ describe('GithubTeams', () => {
75
75
76
76
77
77
it ( 'should resolve with false if \'get()\' rejects' , done => {
78
- githubApi . get . and . returnValue ( Promise . reject ( null ) ) ;
78
+ githubApi . get . and . callFake ( ( ) => Promise . reject ( null ) ) ;
79
79
teams . isMemberById ( 'user' , [ 1 ] ) . then ( isMember => {
80
80
expect ( isMember ) . toBe ( false ) ;
81
81
expect ( githubApi . get ) . toHaveBeenCalled ( ) ;
@@ -85,7 +85,7 @@ describe('GithubTeams', () => {
85
85
86
86
87
87
it ( 'should resolve with false if the membership is not active' , done => {
88
- githubApi . get . and . returnValue ( Promise . resolve ( { state : 'pending' } ) ) ;
88
+ githubApi . get . and . callFake ( ( ) => Promise . resolve ( { state : 'pending' } ) ) ;
89
89
teams . isMemberById ( 'user' , [ 1 ] ) . then ( isMember => {
90
90
expect ( isMember ) . toBe ( false ) ;
91
91
expect ( githubApi . get ) . toHaveBeenCalled ( ) ;
@@ -95,7 +95,7 @@ describe('GithubTeams', () => {
95
95
96
96
97
97
it ( 'should resolve with true if the membership is active' , done => {
98
- githubApi . get . and . returnValue ( Promise . resolve ( { state : 'active' } ) ) ;
98
+ githubApi . get . and . callFake ( ( ) => Promise . resolve ( { state : 'active' } ) ) ;
99
99
teams . isMemberById ( 'user' , [ 1 ] ) . then ( isMember => {
100
100
expect ( isMember ) . toBe ( true ) ;
101
101
done ( ) ;
@@ -175,7 +175,7 @@ describe('GithubTeams', () => {
175
175
176
176
177
177
it ( 'should resolve with false if \'fetchAll()\' rejects' , done => {
178
- teamsFetchAllSpy . and . returnValue ( Promise . reject ( null ) ) ;
178
+ teamsFetchAllSpy . and . callFake ( ( ) => Promise . reject ( null ) ) ;
179
179
teams . isMemberBySlug ( 'user' , [ 'team-slug' ] ) . then ( isMember => {
180
180
expect ( isMember ) . toBe ( false ) ;
181
181
done ( ) ;
@@ -203,7 +203,7 @@ describe('GithubTeams', () => {
203
203
204
204
205
205
it ( 'should resolve with false if \'isMemberById()\' rejects' , done => {
206
- teamsIsMemberByIdSpy . and . returnValue ( Promise . reject ( null ) ) ;
206
+ teamsIsMemberByIdSpy . and . callFake ( ( ) => Promise . reject ( null ) ) ;
207
207
teams . isMemberBySlug ( 'user' , [ 'team1' ] ) . then ( isMember => {
208
208
expect ( isMember ) . toBe ( false ) ;
209
209
expect ( teamsIsMemberByIdSpy ) . toHaveBeenCalled ( ) ;
@@ -212,16 +212,17 @@ describe('GithubTeams', () => {
212
212
} ) ;
213
213
214
214
215
- it ( 'should resolve with the value \'isMemberById()\' resolves with' , done => {
216
- teamsIsMemberByIdSpy . and . returnValues ( Promise . resolve ( false ) , Promise . resolve ( true ) ) ;
215
+ it ( 'should resolve with the value \'isMemberById()\' resolves with' , async ( ) => {
217
216
218
- Promise . all ( [
219
- teams . isMemberBySlug ( 'user' , [ 'team1' ] ) . then ( isMember => expect ( isMember ) . toBe ( false ) ) ,
220
- teams . isMemberBySlug ( 'user' , [ 'team1' ] ) . then ( isMember => expect ( isMember ) . toBe ( true ) ) ,
221
- ] ) . then ( ( ) => {
222
- expect ( teamsIsMemberByIdSpy ) . toHaveBeenCalledTimes ( 2 ) ;
223
- done ( ) ;
224
- } ) ;
217
+ teamsIsMemberByIdSpy . and . callFake ( ( ) => Promise . resolve ( true ) ) ;
218
+ const isMember1 = await teams . isMemberBySlug ( 'user' , [ 'team1' ] ) ;
219
+ expect ( isMember1 ) . toBe ( true ) ;
220
+ expect ( teamsIsMemberByIdSpy ) . toHaveBeenCalledWith ( 'user' , [ 1 ] ) ;
221
+
222
+ teamsIsMemberByIdSpy . and . callFake ( ( ) => Promise . resolve ( false ) ) ;
223
+ const isMember2 = await teams . isMemberBySlug ( 'user' , [ 'team1' ] ) ;
224
+ expect ( isMember2 ) . toBe ( false ) ;
225
+ expect ( teamsIsMemberByIdSpy ) . toHaveBeenCalledWith ( 'user' , [ 1 ] ) ;
225
226
} ) ;
226
227
227
228
} ) ;
0 commit comments