1c32db68da
Implements the beginnings of unit testing infrastructure using mocha/chai. The unit tests can be run locally using test/runtests.sh, although this will need tweaks to run on Windows. They should also run on commit using Travis-CI. The unit tests themselves live in test/tests. The index.js file specifies separate test sets, which can be run individually by calling test/runtests.sh <testsets>. Right now there is only a single unit test, but hopefully we'll have more soon...
20 lines
797 B
JavaScript
20 lines
797 B
JavaScript
describe("Zotero.Utilities", function() {
|
|
describe("cleanAuthor", function() {
|
|
it('should parse author names', function() {
|
|
for(let useComma of [false, true]) {
|
|
for(let first_expected of [["First", "First"],
|
|
["First Middle", "First Middle"],
|
|
["F. R. S.", "F. R. S."],
|
|
["F.R.S.", "F. R. S."],
|
|
["F R S", "F. R. S."],
|
|
["FRS", "F. R. S."]]) {
|
|
let [first, expected] = first_expected;
|
|
let str = useComma ? "Last, "+first : first+" Last";
|
|
let author = Zotero.Utilities.cleanAuthor(str, "author", useComma);
|
|
assert.equal(author.firstName, expected);
|
|
assert.equal(author.lastName, "Last");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|