var $ = jQuery, formatter = require( '../../src/formatter' ); QUnit.module( 'ext.popups.formatter', { beforeEach: function () { window.mediaWiki.RegExp = { escape: this.sandbox.spy( function ( str ) { return str.replace( /([\\{}()|.?*+\-\^$\[\]])/g, '\\$1' ); } ) }; }, afterEach: function () { window.mediaWiki.RegExp = null; } } ); QUnit.test( 'Title is bold', function ( assert ) { var cases = [ [ 'Isaac Newton was born in', 'Isaac Newton', 'Isaac Newton was born in', 'Title as first word' ], [ 'The C* language not to be confused with C# or C', 'C*', 'The C* language not to be confused with C# or C', 'Title containing *' ], [ 'I like trains', 'Train', 'I like trains', 'Make the simple plural bold' ], [ 'Foo\'s pub is a pub in Bar', 'Foo\'s pub', 'Foo\'s pub is a pub in Bar', 'Correct escaping' ], [ '\"Heroes\" is a David Bowie album', '\"Heroes\"', '\"Heroes\" is a David Bowie album', 'Quotes in title' ], [ '*Testing if Things are correctly identified', 'Things', '*Testing if Things are correctly identified', 'Article that begins with asterisk' ], [ 'Testing if repeated words are not matched when repeated', 'Repeated', 'Testing if repeated words are not matched when repeated', 'Repeated title' ] ]; function test( extract, title, expected, msg ) { var $div = $( '