Use ISO 8601 accessDates everywhere

This uses ISO 8601 dates for generateAllTypesAndFieldsData (and
changes populateDBWithSampleData to use Item#fromJSON), and makes
translators expect ISO 8601 accessDates, although SQL accessDates are
still supported with a deprecation warning. Canonicalization happens in
Zotero.Translate, so I need to remember to update connectors as well.
This commit is contained in:
Simon Kornblith 2015-06-07 18:38:00 -04:00
parent 8448203583
commit 70f021f945
7 changed files with 78 additions and 63 deletions

View file

@ -183,6 +183,16 @@ describe("Zotero.Translate", function() {
assert.deepEqual(savedItems, trueItems, "saved items match inputs");
});
it('should accept deprecated SQL accessDates', function* () {
let myItem = {
"itemType":"webpage",
"title":"Test Item",
"accessDate":"2015-01-02 03:04:05"
}
let newItems = yield saveItemsThroughTranslator("import", [myItem]);
assert.equal(newItems[0].getField("accessDate"), "2015-01-02 03:04:05");
});
it('should save tags', function* () {
let myItem = {
"itemType":"book",
@ -392,6 +402,19 @@ describe("Zotero.Translate", function() {
assert.equal(newItems[0].getAttachments().length, 0);
});
it('web translators should set accessDate to current date', function* () {
let myItem = {
"itemType":"webpage",
"title":"Test Item",
"url":"http://www.zotero.org/"
};
let newItems = yield saveItemsThroughTranslator("web", [myItem]);
let currentDate = new Date();
let delta = currentDate - Zotero.Date.sqlToDate(newItems[0].getField("accessDate"), true);
assert.isAbove(delta, -500);
assert.isBelow(delta, 5000);
});
it('web translators should save attachments', function* () {
let myItems = [
{