-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cdf9d0
commit e5224fb
Showing
2 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,59 @@ | ||
import {WebPrintingService} from '../../../src/common/iServer/WebPrintingService'; | ||
import { WebPrintingService } from '../../../src/common/iServer/WebPrintingService'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.webPrintingURL; | ||
var initWebPringtingService = () => { | ||
return new WebPrintingService(url); | ||
return new WebPrintingService(url); | ||
} | ||
describe('WebPrintingService', () => { | ||
it("constructor", () => { | ||
var webPrintingService = initWebPringtingService(); | ||
expect(webPrintingService).not.toBeNull(); | ||
expect(webPrintingService.url).toEqual(url); | ||
}); | ||
it("constructor", () => { | ||
var webPrintingService = initWebPringtingService(); | ||
expect(webPrintingService).not.toBeNull(); | ||
expect(webPrintingService.url).toEqual(url); | ||
}); | ||
|
||
it('headers', () => { | ||
let myHeaders = new Headers(); | ||
var webPrintingService = new WebPrintingService(url, { headers: myHeaders }); | ||
expect(webPrintingService).not.toBeNull(); | ||
expect(webPrintingService.headers).not.toBeNull(); | ||
webPrintingService.destroy(); | ||
}); | ||
it('headers', () => { | ||
let myHeaders = new Headers(); | ||
var webPrintingService = new WebPrintingService(url, { headers: myHeaders }); | ||
expect(webPrintingService).not.toBeNull(); | ||
expect(webPrintingService.headers).not.toBeNull(); | ||
webPrintingService.destroy(); | ||
}); | ||
|
||
it('crossOrigin', () => { | ||
var webPrintingService = new WebPrintingService(url, { crossOrigin: false }); | ||
expect(webPrintingService).not.toBeNull(); | ||
expect(webPrintingService.crossOrigin).toBeFalsy(); | ||
webPrintingService.destroy(); | ||
}); | ||
it('crossOrigin', () => { | ||
var webPrintingService = new WebPrintingService(url, { crossOrigin: false }); | ||
expect(webPrintingService).not.toBeNull(); | ||
expect(webPrintingService.crossOrigin).toBeFalsy(); | ||
webPrintingService.destroy(); | ||
}); | ||
|
||
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(); | ||
} | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.