Fix nesting of resetUnsyncedLibraryFiles() test
This commit is contained in:
parent
637acbe693
commit
cec1f18670
1 changed files with 47 additions and 46 deletions
|
@ -306,52 +306,6 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("#resetUnsyncedLibraryFiles", function () {
|
|
||||||
it("should delete unsynced files", function* () {
|
|
||||||
var group = yield createGroup({
|
|
||||||
version: 1,
|
|
||||||
libraryVersion: 2
|
|
||||||
});
|
|
||||||
var libraryID = group.libraryID;
|
|
||||||
|
|
||||||
// File attachment that's totally in sync -- leave alone
|
|
||||||
var attachment1 = yield importFileAttachment('test.png', { libraryID });
|
|
||||||
attachment1.attachmentSyncState = "in_sync";
|
|
||||||
attachment1.attachmentSyncedModificationTime = yield attachment1.attachmentModificationTime;
|
|
||||||
attachment1.attachmentSyncedHash = yield attachment1.attachmentHash;
|
|
||||||
attachment1.synced = true;
|
|
||||||
yield attachment1.saveTx({
|
|
||||||
skipSyncedUpdate: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// File attachment that's in sync with changed file -- delete file and mark for download
|
|
||||||
var attachment2 = yield importFileAttachment('test.png', { libraryID });
|
|
||||||
attachment2.synced = true;
|
|
||||||
yield attachment2.saveTx({
|
|
||||||
skipSyncedUpdate: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// File attachment that's unsynced -- delete item and file
|
|
||||||
var attachment3 = yield importFileAttachment('test.pdf', { libraryID });
|
|
||||||
|
|
||||||
// Has to be called before resetUnsyncedLibraryFiles()
|
|
||||||
assert.isTrue(yield Zotero.Sync.Data.Local._libraryHasUnsyncedFiles(libraryID));
|
|
||||||
|
|
||||||
yield Zotero.Sync.Data.Local.resetUnsyncedLibraryFiles(libraryID);
|
|
||||||
|
|
||||||
assert.isTrue(yield attachment1.fileExists());
|
|
||||||
assert.isFalse(yield attachment2.fileExists());
|
|
||||||
assert.isFalse(yield attachment3.fileExists());
|
|
||||||
assert.equal(
|
|
||||||
attachment1.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_IN_SYNC
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
attachment2.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_TO_DOWNLOAD
|
|
||||||
);
|
|
||||||
assert.isFalse(Zotero.Items.get(attachment3.id));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should revert modified file attachment item", async function () {
|
it("should revert modified file attachment item", async function () {
|
||||||
var group = await createGroup({
|
var group = await createGroup({
|
||||||
version: 1,
|
version: 1,
|
||||||
|
@ -399,6 +353,53 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe("#resetUnsyncedLibraryFiles()", function () {
|
||||||
|
it("should delete unsynced files", function* () {
|
||||||
|
var group = yield createGroup({
|
||||||
|
version: 1,
|
||||||
|
libraryVersion: 2
|
||||||
|
});
|
||||||
|
var libraryID = group.libraryID;
|
||||||
|
|
||||||
|
// File attachment that's totally in sync -- leave alone
|
||||||
|
var attachment1 = yield importFileAttachment('test.png', { libraryID });
|
||||||
|
attachment1.attachmentSyncState = "in_sync";
|
||||||
|
attachment1.attachmentSyncedModificationTime = yield attachment1.attachmentModificationTime;
|
||||||
|
attachment1.attachmentSyncedHash = yield attachment1.attachmentHash;
|
||||||
|
attachment1.synced = true;
|
||||||
|
yield attachment1.saveTx({
|
||||||
|
skipSyncedUpdate: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// File attachment that's in sync with changed file -- delete file and mark for download
|
||||||
|
var attachment2 = yield importFileAttachment('test.png', { libraryID });
|
||||||
|
attachment2.synced = true;
|
||||||
|
yield attachment2.saveTx({
|
||||||
|
skipSyncedUpdate: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// File attachment that's unsynced -- delete item and file
|
||||||
|
var attachment3 = yield importFileAttachment('test.pdf', { libraryID });
|
||||||
|
|
||||||
|
// Has to be called before resetUnsyncedLibraryFiles()
|
||||||
|
assert.isTrue(yield Zotero.Sync.Data.Local._libraryHasUnsyncedFiles(libraryID));
|
||||||
|
|
||||||
|
yield Zotero.Sync.Data.Local.resetUnsyncedLibraryFiles(libraryID);
|
||||||
|
|
||||||
|
assert.isTrue(yield attachment1.fileExists());
|
||||||
|
assert.isFalse(yield attachment2.fileExists());
|
||||||
|
assert.isFalse(yield attachment3.fileExists());
|
||||||
|
assert.equal(
|
||||||
|
attachment1.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_IN_SYNC
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
attachment2.attachmentSyncState, Zotero.Sync.Storage.Local.SYNC_STATE_TO_DOWNLOAD
|
||||||
|
);
|
||||||
|
assert.isFalse(Zotero.Items.get(attachment3.id));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("#getLatestCacheObjectVersions", function () {
|
describe("#getLatestCacheObjectVersions", function () {
|
||||||
before(function* () {
|
before(function* () {
|
||||||
yield resetDB({
|
yield resetDB({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue