Debian Codegraph @

extensions/MultimediaViewer/tests/qunit/mmv/model/mmv.model.test.js

raw symbols SCIP
1 /*
2 * This file is part of the MediaWiki extension MultimediaViewer.
3 *
4 * MultimediaViewer is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * MultimediaViewer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
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 }() );