Skip to content

Commit 2fc6def

Browse files
committed
Forgot sms.js
1 parent 48550f0 commit 2fc6def

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

tests/sms.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
describe("sms", function() {
2+
3+
describe("#verifyUserMobilePhone", function(){
4+
this.timeout(10000);
5+
it("should be verified", function(done){
6+
var user = new AV.User();
7+
user.set("username", "dennis");
8+
user.set("password", "123456");
9+
user.setMobilePhoneNumber('18668012283');
10+
11+
user.signUp(null, {
12+
success: function(user) {
13+
AV.User.requestMobilePhoneVerify('18668012283').then(function(){
14+
AV.User.logInWithMobilePhone('18668012283',
15+
'123456').then(function(user){
16+
console.dir(user);
17+
expect(user.get('mobilePhoneVerified')).to.be(false);
18+
AV.User.requestLoginSmsCode('18668012283').then(function(){
19+
throw "Unverfied.";
20+
}, function(err){
21+
user.destroy().then(function(){
22+
done();
23+
});
24+
});
25+
}, function(err){
26+
throw err;
27+
});
28+
29+
},function(err){
30+
throw err;
31+
});
32+
},
33+
error: function(user, error) {
34+
throw error;
35+
}
36+
});
37+
});
38+
});
39+
40+
describe("#requestSmsCode", function(){
41+
it("should send sms code.", function(done){
42+
AV.Cloud.requestSmsCode('18668012283').then(function(){
43+
AV.Cloud.requestSmsCode({
44+
mobilePhoneNumber: '18668012283',
45+
name: '测试啊',
46+
op: '测试操作',
47+
ttl: 5
48+
}).then(function(){
49+
done();
50+
}, function(err){
51+
throw err;
52+
});
53+
}, function(err){
54+
throw err;
55+
});
56+
});
57+
});
58+
});

0 commit comments

Comments
 (0)