This repository was archived by the owner on Dec 29, 2022. It is now read-only.
forked from cornerstonejs/cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdateImage_test.js
More file actions
63 lines (51 loc) · 1.41 KB
/
Copy pathupdateImage_test.js
File metadata and controls
63 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { assert } from 'chai';
import enable from '../src/enable.js';
import displayImage from '../src/displayImage.js';
import updateImage from '../src/updateImage.js';
import disable from '../src/disable.js';
describe('Update a displayed image', function () {
beforeEach(function () {
// Arrange
this.element = document.createElement('div');
const options = {};
const height = 2;
const width = 2;
const getPixelData = () => new Uint8Array([0, 255, 255, 0]);
this.image = {
imageId: 'exampleImageId',
minPixelValue: 0,
maxPixelValue: 255,
slope: 1.0,
intercept: 0,
windowCenter: 127,
windowWidth: 256,
getPixelData,
rows: height,
columns: width,
height,
width,
color: false,
sizeInBytes: width * height * 2
};
enable(this.element, options);
});
it('should fire CornerstoneImageRendered', function (done) {
const element = this.element;
const image = this.image;
displayImage(element, image);
// Act
updateImage(element);
// Assert
element.addEventListener('cornerstoneimagerendered', function (event) {
assert.equal(event.target, element);
done();
});
});
it('should throw an Error if the image is not loaded', function () {
// Act
assert.throws(() => updateImage(this.element));
});
afterEach(function () {
disable(this.element);
});
});