libreoffice-online/loleaflet/mocha_tests/CBounds.test.ts
Dennis Francis 09e956ef3a add CBounds.fromCompat() tests
Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: Ibca9d4c3e18a027f0b3842c434143076daba436f
2021-02-26 21:48:15 +05:30

54 lines
No EOL
1.5 KiB
TypeScript

/// <reference path="../src/layer/vector/CPoint.ts" />
/// <reference path="../src/layer/vector/CBounds.ts" />
var assert = require('assert').strict;
describe('CBounds parse() tests', function () {
describe('CBounds.parse() call with an empty string argument', function () {
it('should return undefined', function () {
assert.equal(CBounds.parse(''), undefined);
});
});
describe('CBounds.parse() call with an string argument with 3 numbers', function () {
it('should return undefined', function () {
assert.equal(CBounds.parse('10 20 30'), undefined);
});
});
describe('CBounds.parse() call with an string argument with 4 numbers', function () {
var bounds = CBounds.parse('10 20 30 40');
it('should return a valid CBounds', function () {
assert.ok(bounds instanceof CBounds);
assert.ok(bounds.isValid());
});
it('and the CBounds should be correct in position and size', function () {
assert.ok(bounds.equals(new CBounds(new CPoint(10, 20), new CPoint(40, 60))));
});
});
});
describe('CBounds fromCompat() tests', function () {
describe('CBounds.fromCompat() with a CBounds like object', function () {
it('should return correct CBounds object', function () {
var compatBoundsObj = {
min: {
x: 34,
y: 56
},
max: {
x: 94,
y: 76
}
};
assert.ok(CBounds.fromCompat(compatBoundsObj).equals(
new CBounds(
new CPoint(compatBoundsObj.min.x, compatBoundsObj.min.y),
new CPoint(compatBoundsObj.max.x, compatBoundsObj.max.y))
));
});
});
});