3
3
//
4
4
// Modules are of the following formats
5
5
//
6
- describe ( 'Modules all' , function ( ) {
7
6
8
- var MATCH_URL = / ^ h t t p s ? \: \/ \/ / ;
7
+ // Loop through all services
8
+ for ( var name in hello . services ) {
9
+ setup_module_tests ( hello . services [ name ] , name ) ;
10
+ }
9
11
10
- it ( 'contain oauth or url.auth paths' , function ( ) {
12
+ function setup_module_tests ( module , name ) {
11
13
12
- // Loop through all services
13
- for ( var name in hello . services ) {
14
- var path = hello . services [ name ] . oauth . auth ;
14
+ describe ( module . name || name + ' Module' , function ( ) {
15
+
16
+ var MATCH_URL = / ^ h t t p s ? \: \/ \/ / ;
17
+
18
+ it ( 'contain oauth.auth path' , function ( ) {
19
+ var path = module . oauth . auth ;
15
20
expect ( path ) . to . match ( / ^ h t t p s ? \: \/ \/ / ) ;
16
- }
17
- } ) ;
21
+ } ) ;
22
+
23
+ it ( 'specify a base url' , function ( ) {
24
+ // Loop through all services
25
+ expect ( module . base ) . to . match ( / ^ h t t p s ? \: \/ \/ / ) ;
26
+ } ) ;
18
27
19
28
20
- it ( 'using OAuth1 contain, auth, request, token properties' , function ( ) {
29
+ it ( 'using OAuth1 contain, auth, request, token properties' , function ( ) {
21
30
22
- // Loop through all services
23
- for ( var name in hello . services ) {
24
- var oauth = hello . services [ name ] . oauth ;
31
+ // Loop through all services
32
+ var oauth = module . oauth ;
25
33
if ( oauth && parseInt ( oauth . version , 10 ) === 1 ) {
26
34
expect ( oauth . auth ) . to . match ( MATCH_URL ) ;
27
35
expect ( oauth . token ) . to . match ( MATCH_URL ) ;
28
36
expect ( oauth . request ) . to . match ( MATCH_URL ) ;
29
37
}
30
- }
31
- } ) ;
32
-
33
- it ( 'return error object when an api request is made with an unverified user' , function ( done ) {
34
-
35
- this . timeout ( 60000 ) ;
36
-
37
- var i = 0 ;
38
+ } ) ;
38
39
39
- function contains_error_callback ( data ) {
40
+ it ( 'return error object when an api request is made with an unverified user' , function ( done ) {
40
41
41
- expect ( data ) . to . be . a ( "object" ) ;
42
- expect ( data ) . to . have . property ( "error" ) ;
43
- expect ( data . error ) . to . have . property ( "code" ) ;
44
- expect ( data . error ) . to . have . property ( "message" ) ;
45
- expect ( data . error . code ) . to . not . be . an ( "object" ) ;
46
- expect ( data . error . message ) . to . not . be . an ( "object" ) ;
47
-
48
- if ( -- i <= 0 ) {
49
- done ( ) ;
50
- }
51
- }
52
-
53
- // Loop through all services
54
- for ( var name in hello . services ) {
55
- // i++
56
- i ++ ;
42
+ this . timeout ( 60000 ) ;
57
43
58
44
// ensure user is signed out
59
45
hello . logout ( name ) ;
60
46
61
47
// Make a request that returns an error object
62
- hello ( name ) . api ( 'me' , contains_error_callback ) ;
63
- }
64
- } ) ;
65
- /**/
48
+ hello ( name ) . api ( 'me' , function ( data ) {
49
+ expect ( data ) . to . be . a ( "object" ) ;
50
+ expect ( data ) . to . have . property ( "error" ) ;
51
+ expect ( data . error ) . to . have . property ( "code" ) ;
52
+ expect ( data . error ) . to . have . property ( "message" ) ;
53
+ expect ( data . error . code ) . to . not . be . an ( "object" ) ;
54
+ expect ( data . error . message ) . to . not . be . an ( "object" ) ;
55
+ done ( ) ;
56
+ } ) ;
57
+ } ) ;
58
+ /**/
66
59
67
- } ) ;
60
+ } ) ;
61
+ }
0 commit comments