@@ -6,17 +6,20 @@ import apiKey from './ApiKey.js';
66import axios from 'axios' ;
77
88describe ( 'JobsResource' , ( ) => {
9+ let cloudConvert : CloudConvert ;
10+ let tmpPath : string ;
11+
912 beforeEach ( ( ) => {
10- this . cloudConvert = new CloudConvert ( apiKey , true ) ;
13+ cloudConvert = new CloudConvert ( apiKey , true ) ;
1114 } ) ;
1215
1316 describe ( 'create()' , ( ) => {
1417 beforeEach ( ( ) => {
15- this . tmpPath = os . tmpdir ( ) + '/tmp.png' ;
18+ tmpPath = os . tmpdir ( ) + '/tmp.png' ;
1619 } ) ;
1720
1821 it ( 'test upload and download files' , async ( ) => {
19- let job = await this . cloudConvert . jobs . create ( {
22+ let job = await cloudConvert . jobs . create ( {
2023 tag : 'integration-test-upload-download' ,
2124 tasks : {
2225 'import-it' : { operation : 'import/upload' } ,
@@ -32,18 +35,18 @@ describe('JobsResource', () => {
3235 __dirname + '/../integration/files/input.png'
3336 ) ;
3437
35- await this . cloudConvert . tasks . upload ( uploadTask , stream ) ;
38+ await cloudConvert . tasks . upload ( uploadTask , stream ) ;
3639
37- job = await this . cloudConvert . jobs . wait ( job . id ) ;
40+ job = await cloudConvert . jobs . wait ( job . id ) ;
3841
3942 assert . equal ( job . status , 'finished' ) ;
4043
4144 // download export file
42- const file = this . cloudConvert . jobs . getExportUrls ( job ) [ 0 ] ;
45+ const file = cloudConvert . jobs . getExportUrls ( job ) [ 0 ] ;
4346
4447 assert . equal ( file . filename , 'input.png' ) ;
4548
46- const writer = fs . createWriteStream ( this . tmpPath ) ;
49+ const writer = fs . createWriteStream ( tmpPath ) ;
4750
4851 const response = await axios ( file . url , { responseType : 'stream' } ) ;
4952
@@ -55,21 +58,21 @@ describe('JobsResource', () => {
5558 } ) ;
5659
5760 // check file size
58- const stat = fs . statSync ( this . tmpPath ) ;
61+ const stat = fs . statSync ( tmpPath ) ;
5962
6063 assert . equal ( stat . size , 46937 ) ;
6164
62- await this . cloudConvert . jobs . delete ( job . id ) ;
65+ await cloudConvert . jobs . delete ( job . id ) ;
6366 } ) . timeout ( 30000 ) ;
6467
6568 afterEach ( ( ) => {
66- fs . unlinkSync ( this . tmpPath ) ;
69+ fs . unlinkSync ( tmpPath ) ;
6770 } ) ;
6871 } ) ;
6972
7073 describe ( 'subscribeEvent()' , ( ) => {
7174 it ( 'test listening for finished event' , async ( ) => {
72- let job = await this . cloudConvert . jobs . create ( {
75+ const job = await cloudConvert . jobs . create ( {
7376 tag : 'integration-test-socket' ,
7477 tasks : {
7578 'import-it' : { operation : 'import/upload' } ,
@@ -85,23 +88,19 @@ describe('JobsResource', () => {
8588 __dirname + '/../integration/files/input.png'
8689 ) ;
8790
88- this . cloudConvert . tasks . upload ( uploadTask , stream ) ;
91+ cloudConvert . tasks . upload ( uploadTask , stream ) ;
8992
9093 const event = await new Promise ( resolve => {
91- this . cloudConvert . jobs . subscribeEvent (
92- job . id ,
93- 'finished' ,
94- resolve
95- ) ;
94+ cloudConvert . jobs . subscribeEvent ( job . id , 'finished' , resolve ) ;
9695 } ) ;
9796
9897 assert . equal ( event . job . status , 'finished' ) ;
9998
100- await this . cloudConvert . jobs . delete ( job . id ) ;
99+ await cloudConvert . jobs . delete ( job . id ) ;
101100 } ) . timeout ( 30000 ) ;
102101
103102 afterEach ( ( ) => {
104- this . cloudConvert . closeSocket ( ) ;
103+ cloudConvert . closeSocket ( ) ;
105104 } ) ;
106105 } ) ;
107106} ) ;
0 commit comments