mediawiki-skins-MinervaNeue/tests/qunit/skins.minerva.scripts/UriUtil.test.js
Jdrewniak dbe79167e5 Revert "tests: Adopt private require() for skins.minerva.scripts"
This reverts commit 548e94da98.

Reason for revert: The patch was causing the following error on pageload

    Error: Cannot require undefined file includes/Skins/ToggleList/ToggleList.js
    require startup.js:1006

Bug: T373482
Change-Id: I22751109c124795af7d2e0ad6c4104745b2d6632
2024-08-27 20:06:24 +00:00

41 lines
1.1 KiB
JavaScript

( function () {
const UriUtil = require( '../../../resources/skins.minerva.scripts/UriUtil.js' );
const mwUriOrg = mw.Uri;
QUnit.module( 'Minerva UriUtil', {
beforeEach: function () {
mw.Uri = mw.UriRelative( 'https://meta.wikimedia.org/w/index.php' );
},
afterEach: function () {
mw.Uri = mwUriOrg;
}
} );
QUnit.test( '.isInternal()', ( assert ) => {
assert.true(
UriUtil.isInternal( new mw.Uri( '/relative' ) ),
'relative URLs are internal'
);
assert.true(
UriUtil.isInternal( new mw.Uri( 'http://meta.wikimedia.org/' ) ),
'matching hosts are internal'
);
assert.true(
UriUtil.isInternal( new mw.Uri( 'https:/meta.wikimedia.org/' ) ),
'protocol is irrelevant'
);
assert.true(
UriUtil.isInternal( new mw.Uri( 'https://meta.wikimedia.org/path' ) ),
'path is irrelevant'
);
assert.false(
UriUtil.isInternal( new mw.Uri( 'https://archive.org/' ) ),
'external links are not internal'
);
assert.false(
UriUtil.isInternal( new mw.Uri( 'https://www.meta.wikimedia.org/' ) ),
'differing subdomains are not internal'
);
} );
}() );