123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- var should = require( 'should' );
- var _ = require( 'underscore' );
- var testConfig = require( './config' );
- var rongSDK = require( '../index' );
- var groupIDs = _.keys( testConfig.group.groupIdNamePairs );
- var groupNames = _.values( testConfig.group.groupIdNamePairs );
- describe( 'Group Test', function() {
- before( function( done ) {
- // Init the SDK before testing.
- rongSDK.init( testConfig.appKey, testConfig.appSecret );
- done();
- } );
- after( function( done ) {
- done();
- } );
- describe( 'Sync Group', function() {
- it( 'Synchornize group: should return OK', function( done ) {
- rongSDK.group.sync( testConfig.group.userId, testConfig.group.groupIdNamePairs, function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- } );
- describe( 'Quit Group', function() {
- it( 'Quit group: should return OK', function( done ) {
- rongSDK.group.quit( testConfig.group.userId, groupIDs[0], function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- } );
- describe( 'Create/Join Group', function() {
- it( 'Create/Join group with a single user: should return OK', function( done ) {
- rongSDK.group.create( testConfig.group.userId, 'MyGroupID', 'MyGroupName' , function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- it( 'Create/Join group with multiple users: should return OK', function( done ) {
- rongSDK.group.join( [ testConfig.message.fromUserId, testConfig.message.toUserId ], 'MyGroupID', 'MyGroupName' , function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- } );
- describe( 'Dissmiss Group', function() {
- it( 'Dismiss group(' + groupNames[0] + '): should return OK', function( done ) {
- rongSDK.group.dismiss( testConfig.group.userId, groupIDs[0], function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- it( 'Dismiss group(' + groupNames[1] + '): should return OK', function( done ) {
- rongSDK.group.dismiss( testConfig.group.userId, groupIDs[1], function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- it( 'Dismiss group(MyGroupName): should return OK', function( done ) {
- rongSDK.group.dismiss( testConfig.group.userId, 'MyGroupID', function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- } );
- describe( 'Refresh Group', function() {
- var newGroupName = groupNames[0];
- it( 'Refresh group(' + groupNames[0] + ') to be ' + newGroupName + ': should return OK', function( done ) {
- rongSDK.group.refresh( groupIDs[0], newGroupName, function( err, resultText ) {
- should.not.exists( err );
- var result = JSON.parse( resultText );
- result.code.should.equal( 200 );
- done();
- } );
- } );
- });
- } );
|