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