mirror of
https://github.com/novnc/noVNC.git
synced 2026-05-26 15:13:34 +00:00
When run via karma, all the tests are loaded into the same page. This was causing a collision in the 'displayed' assertion dealing with using viewportLoc. The assertions are now in their own file, pulled in by tests that need them. Additionally, several tests which only set fb_width and fb_height were correct to set viewportLoc as well. Closes #392 Also-Authored-By: Martin André (github: mandre)
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
// some useful assertions for noVNC
|
|
chai.use(function (_chai, utils) {
|
|
_chai.Assertion.addMethod('displayed', function (target_data) {
|
|
var obj = this._obj;
|
|
var data_cl = obj._drawCtx.getImageData(0, 0, obj._viewportLoc.w, obj._viewportLoc.h).data;
|
|
// NB(directxman12): PhantomJS 1.x doesn't implement Uint8ClampedArray, so work around that
|
|
var data = new Uint8Array(data_cl);
|
|
this.assert(utils.eql(data, target_data),
|
|
"expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}",
|
|
"expected #{this} not to have displayed the image #{act}",
|
|
target_data,
|
|
data);
|
|
});
|
|
|
|
_chai.Assertion.addMethod('sent', function (target_data) {
|
|
var obj = this._obj;
|
|
var data = obj._websocket._get_sent_data();
|
|
this.assert(utils.eql(data, target_data),
|
|
"expected #{this} to have sent the data #{exp}, but it actually sent #{act}",
|
|
"expected #{this} not to have sent the data #{act}",
|
|
target_data,
|
|
data);
|
|
});
|
|
});
|