@@ -2,6 +2,7 @@ var chai = require('chai'),
2
2
assert = chai . assert ,
3
3
SMSAPI = require ( '../lib/smsapi' ) ,
4
4
config = require ( './config' ) ,
5
+ randomString = require ( 'randomstring' ) . generate ,
5
6
_ = require ( 'lodash' ) ;
6
7
7
8
var optionsByAuth = {
@@ -17,7 +18,8 @@ var optionsByAuth = {
17
18
_ . forEach ( optionsByAuth , function ( options , authName ) {
18
19
19
20
describe ( 'user (' + authName + ')' , function ( ) {
20
- var smsapi = new SMSAPI ( options ) ;
21
+ var smsapi = new SMSAPI ( options ) ,
22
+ userName = ( 'test-' + randomString ( ) ) . substring ( 0 , 10 ) ;
21
23
22
24
if ( authName === 'AuthenticationSimple' ) {
23
25
before ( function ( done ) {
@@ -41,7 +43,7 @@ _.forEach(optionsByAuth, function (options, authName) {
41
43
it ( 'should add new subuser' , function ( done ) {
42
44
smsapi . user
43
45
. add ( )
44
- . name ( 'TestSubuser' )
46
+ . name ( userName )
45
47
. pass ( 'SubuserPassword' )
46
48
. execute ( )
47
49
. then ( function ( result ) {
@@ -64,7 +66,7 @@ _.forEach(optionsByAuth, function (options, authName) {
64
66
65
67
it ( 'should get details of the added subuser' , function ( done ) {
66
68
smsapi . user
67
- . get ( 'TestSubuser' )
69
+ . get ( userName )
68
70
. execute ( )
69
71
. then ( function ( result ) {
70
72
assert . property ( result , 'username' ) ;
@@ -74,16 +76,18 @@ _.forEach(optionsByAuth, function (options, authName) {
74
76
assert . property ( result , 'phonebook' ) ;
75
77
assert . property ( result , 'active' ) ;
76
78
assert . property ( result , 'info' ) ;
77
- assert . match ( result . username , / T e s t S u b u s e r / ) ;
79
+ assert . match ( result . username , new RegExp ( userName , 'g' ) ) ;
78
80
done ( ) ;
79
81
} )
80
82
. catch ( done ) ;
81
83
} ) ;
82
84
83
85
it ( 'should edit added subuser' , function ( done ) {
86
+ var infoContent = 'Test' ;
87
+
84
88
smsapi . user
85
- . update ( 'TestSubuser' )
86
- . limit ( 100 )
89
+ . update ( userName )
90
+ . info ( infoContent )
87
91
. execute ( )
88
92
. then ( function ( result ) {
89
93
assert . property ( result , 'username' ) ;
@@ -93,8 +97,8 @@ _.forEach(optionsByAuth, function (options, authName) {
93
97
assert . property ( result , 'phonebook' ) ;
94
98
assert . property ( result , 'active' ) ;
95
99
assert . property ( result , 'info' ) ;
96
- assert . match ( result . username , / T e s t S u b u s e r / ) ;
97
- assert . equal ( result . limit , 100 ) ;
100
+ assert . match ( result . username , new RegExp ( userName , 'g' ) ) ;
101
+ assert . equal ( result . info , infoContent ) ;
98
102
done ( ) ;
99
103
} )
100
104
. catch ( done ) ;
0 commit comments