| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
const { Thumbnail, ThumbnailWidth } = require( 'mmv' ); |
| 19 |
|
| 20 |
( function () { |
| 21 |
QUnit.module( 'mmv.model', QUnit.newMwEnvironment() ); |
| 22 |
|
| 23 |
QUnit.test( 'Thumbnail constructor sense check', ( assert ) => { |
| 24 |
const width = 23; |
| 25 |
const height = 42; |
| 26 |
const url = 'http://example.com/foo.jpg'; |
| 27 |
let thumbnail = new Thumbnail( url, width, height ); |
| 28 |
|
| 29 |
assert.strictEqual( thumbnail.url, url, 'Url is set correctly' ); |
| 30 |
assert.strictEqual( thumbnail.width, width, 'Width is set correctly' ); |
| 31 |
assert.strictEqual( thumbnail.height, height, 'Height is set correctly' ); |
| 32 |
|
| 33 |
assert.throws( () => { |
| 34 |
thumbnail = new Thumbnail( url, width ); |
| 35 |
}, 'Exception is thrown when parameters are missing' ); |
| 36 |
} ); |
| 37 |
|
| 38 |
QUnit.test( 'ThumbnailWidth constructor sense check', ( assert ) => { |
| 39 |
const cssWidth = 23; |
| 40 |
const cssHeight = 29; |
| 41 |
const screenWidth = 42; |
| 42 |
const realWidth = 123; |
| 43 |
let thumbnailWidth = new ThumbnailWidth( |
| 44 |
cssWidth, cssHeight, screenWidth, realWidth ); |
| 45 |
|
| 46 |
assert.strictEqual( thumbnailWidth.cssWidth, cssWidth, 'Width is set correctly' ); |
| 47 |
assert.strictEqual( thumbnailWidth.cssHeight, cssHeight, 'Height is set correctly' ); |
| 48 |
assert.strictEqual( thumbnailWidth.screen, screenWidth, 'Screen width is set correctly' ); |
| 49 |
assert.strictEqual( thumbnailWidth.real, realWidth, 'Real width is set correctly' ); |
| 50 |
|
| 51 |
assert.throws( () => { |
| 52 |
thumbnailWidth = new ThumbnailWidth( cssWidth, screenWidth ); |
| 53 |
}, 'Exception is thrown when parameters are missing' ); |
| 54 |
} ); |
| 55 |
|
| 56 |
}() ); |