Add unit test for "America, the Beautiful" article redirection.

The expected redirection behavior is described on #106
This commit is contained in:
mossroy 2016-04-29 08:59:56 +02:00
parent 0c2f340029
commit f6ad260867
2 changed files with 20 additions and 5 deletions

View File

@ -39,11 +39,8 @@
</head>
<body>
Depending on the browser you use, you should launch these unit tests differently : <br/>
<ul>
<li>Open this page from a file:/// URL for Firefox (for a reason I have to find, there's an error when running from an http://localhost URL)</li>
<li>Open this page from a http:// URL for Chromium/Chrome (through a local webserver, for example), because it does not allow to run a web worker from a file:/// URL</li>
</ul>
These unit tests should be run with Firefox.<br/>
TODO : find out why they do not all run on Chromium
<div id="qunit"></div>
</body>
</html>

View File

@ -609,6 +609,24 @@ define(['jquery', 'title', 'archive', 'zimArchive', 'zimDirEntry', 'util', 'geom
}
}).fail(errorHandlerAsyncTest);
});
asyncTest("article 'America, the Beautiful' correctly redirects to 'America the Beautiful'", function() {
expect(6);
localZimArchive.getTitleByName("A/America,_the_Beautiful.html").then(function(title) {
ok(title !== null, "Title found");
if (title !== null) {
ok(title.isRedirect(), "Title is a redirect.");
equal(title.name(), "America, the Beautiful", "Correct redirect title name.");
localZimArchive.resolveRedirect(title, function(title) {
ok(title !== null, "Title found");
ok(!title.isRedirect(), "Title is not a redirect.");
equal(title.name(), "America the Beautiful", "Correct redirected title name.");
start();
});
} else {
start();
}
}).fail(errorHandlerAsyncTest);
});
asyncTest("Image 'm/RayCharles_AManAndHisSoul.jpg' can be loaded", function() {
expect(4);
localZimArchive.getTitleByName("I/m/RayCharles_AManAndHisSoul.jpg").then(function(title) {