User:Evad37/Covery/sandbox.js: Difference between revisions

Content deleted Content added
.
Reverted to revision 863784929 by Evad37 (talk): Mw.loader version of QUnit not working. (TW)
Line 1,012:
};
*/
$('<div>')
 
.attr('id', 'qunit')
.insertBefore('#firstHeading');
return true; // mw.loader.using('jquery.qunit');
}
Line 1,055 ⟶ 1,057:
) {
$.when(setupForTesting(), $.ready()).then(function() {
mw.loader.load('https://code.jquery.com/qunit/qunit-2.6.2.css', 'text/css');
/*window.QUnit = {
$.getScript('https://code.jquery.com/qunit/qunit-2.6.2.js', function() {
config: {
autoStart: false,
}
};
*/
var loadQunit;
try {
loadQunit = mw.loader.using('jquery.qunit')
} catch(e) {
console.log('error while loading QUnit');
console.log(e)
}
loadQunit.then(function() {
 
$('<div>')
.attr('id', 'qunit')
.insertBefore('#firstHeading');
QUnit.module('Get parameters from a template');
QUnit.test('Single unnamed param', function(assert) {
Line 1,100 ⟶ 1,085:
assert.deepEqual(params1, expected1, 'unspaced');
assert.deepEqual(params2, expected2, 'spaced');
});
});
QUnit.test('Two unnamed params', function(assert) {
var params1 = getTemplateParameters('|one|two');
Line 1,143 ⟶ 1,127:
assert.deepEqual(params1, expected1, 'unspaced');
assert.deepEqual(params2, expected2, 'spaced');
});
});
QUnit.test('Single named param', function(assert) {
var params1 = getTemplateParameters('|a=apple');
Line 1,750 ⟶ 1,733:
'==Licensing==\n{{Non-free video game cover|Platform1|Platform2}}';
assert.equal(description, expected, 'Two platforms');
});
});
}); // end of "get script QUnit"
}); // end of "when set up for testing" callback