@@ -3,6 +3,11 @@ describe('Content API', function() {
33
44 var REST_REQUESTS_TIMEOUT = 3000 ;
55
6+ var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object' ;
7+ var QB = isNodeEnv ? require ( '../js/qbMain' ) : window . QB ;
8+ var CREDENTIALS = isNodeEnv ? require ( './config' ) . CREDENTIALS : window . CREDENTIALS ;
9+ var QBUser1 = isNodeEnv ? require ( './config' ) . QBUser1 : window . QBUser1 ;
10+
611 var token ,
712 data = { } ,
813 fileUID = '97f5802dcbd34a59a4921d73f6baedd000' ,
@@ -13,7 +18,7 @@ describe('Content API', function() {
1318
1419 QB . createSession ( QBUser1 , function ( err , session ) {
1520 if ( err ) {
16- done . fail ( " Create session error: " + JSON . stringify ( err ) ) ;
21+ done . fail ( ' Create session error: ' + JSON . stringify ( err ) ) ;
1722 } else {
1823 expect ( session ) . not . toBeNull ( ) ;
1924 token = session . token ;
@@ -24,14 +29,18 @@ describe('Content API', function() {
2429 } , REST_REQUESTS_TIMEOUT ) ;
2530
2631 it ( 'can create and upload files' , function ( done ) {
32+ if ( isNodeEnv ) {
33+ pending ( 'Working on fix "new File" in Node env.' ) ;
34+ }
35+
2736 var d = new Date ( 2015 , 10 , 13 , 14 , 30 , 30 , 600 ) ,
28- genFile = new File ( [ " Hello QuickBlox" ] , " QB.txt" , { type : " text/plain" , lastModified : d } ) ;
37+ genFile = new File ( [ ' Hello QuickBlox' ] , ' QB.txt' , { type : ' text/plain' , lastModified : d } ) ;
2938
3039 data = { name : genFile . name , file : genFile , type : genFile . type , size : genFile . size , public : false } ;
3140
3241 QB . content . createAndUpload ( data , function ( err , res ) {
3342 if ( err ) {
34- done . fail ( " Create and upload files error: " + JSON . stringify ( err ) ) ;
43+ done . fail ( ' Create and upload files error: ' + JSON . stringify ( err ) ) ;
3544 } else {
3645 expect ( res ) . not . toBeNull ( ) ;
3746 expect ( res . name ) . toBe ( 'QB.txt' ) ;
@@ -55,15 +64,19 @@ describe('Content API', function() {
5564 } , REST_REQUESTS_TIMEOUT ) ;
5665
5766 it ( 'can delete content objects' , function ( done ) {
67+ if ( isNodeEnv ) {
68+ pending ( 'Working on fix "new File" in Node env.' ) ;
69+ }
70+
5871 QB . content . createAndUpload ( data , function ( err , response ) {
5972 if ( err ) {
60- done . fail ( " Create and upload files error: " + JSON . stringify ( err ) ) ;
73+ done . fail ( ' Create and upload files error: ' + JSON . stringify ( err ) ) ;
6174 } else {
6275 var elemId = response . id ;
6376
6477 QB . content . delete ( elemId , function ( err , result ) {
6578 if ( err ) {
66- done . fail ( " Delete content objects error: " + JSON . stringify ( err ) ) ;
79+ done . fail ( ' Delete content objects error: ' + JSON . stringify ( err ) ) ;
6780 } else {
6881 expect ( result ) . toEqual ( true ) ;
6982
0 commit comments