File tree 2 files changed +88
-0
lines changed
2 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ *
3
+ * @param {any } body
4
+ * @returns {ResponseHandler }
5
+ */
6
+ function jsonResponse ( body ) {
7
+ return function ( ) {
8
+ return [ 200 , { } , JSON . stringify ( body ) ] ;
9
+ } ;
10
+ }
11
+
12
+ /**
13
+ * @this {Pretender}
14
+ */
15
+ function setupServer ( ) {
16
+ this . get (
17
+ '/api/users' ,
18
+ jsonResponse ( [
19
+ { id : 1 , name : 'Sample McFixture' } ,
20
+ { id : 2 , name : 'Testy Assertington' } ,
21
+ ] )
22
+ ) ;
23
+ this . get (
24
+ '/api/teams' ,
25
+ jsonResponse ( [
26
+ {
27
+ id : 'gh' ,
28
+ name : 'GitHub' ,
29
+ } ,
30
+ ] )
31
+ ) ;
32
+ this . get (
33
+ '/api/teams/gh' ,
34
+ jsonResponse ( {
35
+ id : 'gh' ,
36
+ name : 'GitHub' ,
37
+ channels : [
38
+ {
39
+ id : 'prs' ,
40
+ name : 'Pull Requests' ,
41
+ } ,
42
+ ] ,
43
+ } )
44
+ ) ;
45
+ this . get (
46
+ '/api/teams/gh/channels/prs' ,
47
+ jsonResponse ( {
48
+ id : 'prs' ,
49
+ name : 'Pull Requests' ,
50
+ } )
51
+ ) ;
52
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ *
3
+ * @param {any } body
4
+ * @returns {ResponseHandler }
5
+ */
6
+ function jsonResponse ( body ) {
7
+ return function ( ) {
8
+ return [ 200 , { } , JSON . stringify ( body ) ] ;
9
+ } ;
10
+ }
11
+
12
+ /**
13
+ * @this {Pretender}
14
+ */
15
+ function setupServer ( ) {
16
+ this . get (
17
+ '/api/teams/gh/channels/prs' ,
18
+ jsonResponse ( {
19
+ id : 'prs' ,
20
+ teamId : 'gh' ,
21
+ name : 'Pull Requests' ,
22
+ } )
23
+ ) ;
24
+ this . get (
25
+ '/api/teams/gh/channels/prs/messages' ,
26
+ jsonResponse ( [
27
+ {
28
+ id : 1 ,
29
+ user : {
30
+ name : 'Testy Testerson' ,
31
+ } ,
32
+ body : 'Hello Tests' ,
33
+ } ,
34
+ ] )
35
+ ) ;
36
+ }
You can’t perform that action at this time.
0 commit comments