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

Content deleted Content added
.
.
Line 1,505:
}, infobox + ' throws an error');
});
}
} // end of "check infobox"
 
QUnit.module('Make infobox wikitext');
QUnit.test('Add a param', function(assert) {
var newParams = [{ name: 'image', value: 'Foo.png' }];
var infobox1 = getInfoboxTemplate('{{Infobox Video Game}}');
var wikitext1 = makeInfoboxWikitext(infobox1, newParams);
var expected1 = '{{Infobox Video Game\n|image = Foo.png\n}}';
var infobox2 = getInfoboxTemplate('{{Infobox Video Game\n|developer=DEV\n}}');
var wikitext2 = makeInfoboxWikitext(infobox2, newParams);
var expected2 = '{{Infobox Video Game\n|developer=DEV\n|image = Foo.png\n}}';
assert.equal(wikitext1, expected1, 'Empty infobox');
assert.equal(wikitext2, expected2, 'With one other param');
});
QUnit.test('Override empty param', function(assert) {
var newParams = [{ name: 'image', value: 'Foo.png' }];
var infobox1 = getInfoboxTemplate('{{Infobox Video Game\n| image = \n}}');
var wikitext1 = makeInfoboxWikitext(infobox1, newParams);
var expected1 = '{{Infobox Video Game\n| image = Foo.png\n}}';
var infobox2 = getInfoboxTemplate('{{Infobox Video Game\n| image = \n| developer = DEV\n}}');
var wikitext2 = makeInfoboxWikitext(infobox2, newParams);
var expected2 = '{{Infobox Video Game\n|developer=DEV\n| image = Foo.png\n| developer = DEV\n}}';
assert.equal(wikitext1, expected1, 'Otherwise empty infobox');
assert.equal(wikitext2, expected2, 'With one other param');
});
QUnit.test('Override 1 empty param, 1 non-empty param', function(assert) {
var newParams = [{ name: 'image', value: 'Foo.png' }, {name:'developer', value:'[[DEV]]'}];
var infobox1 = getInfoboxTemplate('{{Infobox Video Game\n| image = \n| developer = NotTheDev\n}}');
var wikitext1 = makeInfoboxWikitext(infobox1, newParams);
var expected1 = '{{Infobox Video Game\n|developer=DEV\n| image = Foo.png\n| developer = [[DEV]]\n}}';
var infobox2 = getInfoboxTemplate('{{Infobox Video Game\n| image = \n| publisher = PUB\n| developer = NotTheDev\n}}');
var wikitext2 = makeInfoboxWikitext(infobox2, newParams);
var expected2 = '{{Infobox Video Game\n|developer=DEV\n| image = Foo.png\n| publisher = PUB\n| developer = [[DEV]]\n}}';
assert.equal(wikitext1, expected1, 'No other params');
assert.equal(wikitext2, expected2, 'With one other param');
});
}); // end of "get script QUnit"
}); // end of "when set up for testing" callback