Skip to content

Commit

Permalink
fix webprint ut
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Apr 8, 2024
1 parent ca60231 commit ac77cd0
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/common/iServer/WebPrintingServiceSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WebPrintingService } from '../../../src/common/iServer/WebPrintingService';
import { FetchRequest } from '../../../src/common/util/FetchRequest';

var url = GlobeParameter.webPrintingURL;
var initWebPringtingService = () => {
Expand Down Expand Up @@ -71,4 +72,34 @@ describe('WebPrintingService', () => {
});
});
});

it('running status not trigger callback', (done) => {
var count = 0;
var webPrintingService = new WebPrintingService(url, { crossOrigin: false });
var jobId = 'e3ff26fa-a0b5-46d3-ad4a-096611a59c03@9fd5defe-d77d-4e17-967e-643c4f34d67e';
spyOn(FetchRequest, 'commit').and.callFake((method, testUrl) => {
count++;
expect(method).toBe('GET');
expect(testUrl).toBe(url + `/jobs/${jobId}`);
if (count === 3) {
return Promise.resolve(new Response(JSON.stringify(getPrintingJobResultJson)));
}
return Promise.resolve(new Response(JSON.stringify(getPrintingJobRunningJson)));
});
webPrintingService.getPrintingJob(jobId, (result) => {
var serviceResult = result;
try {
expect(serviceResult).not.toBeNull();
expect(serviceResult.type).toBe('processCompleted');
expect(serviceResult.result).not.toBeNull();
expect(serviceResult.result.id).toEqual(jobId);
expect(serviceResult.result.status).toEqual('FINISHED');
done();
} catch (e) {
console.log("'getPrintingJob'案例失败" + e.name + ':' + e.message);
expect(false).toBeTruthy();
done();
}
});
});
});
46 changes: 46 additions & 0 deletions test/resources/WebPrintingJobService.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac77cd0

Please sign in to comment.