VulpesOS/gaia/apps/sharedtest/test/unit/sync/sync-engine/adapter-mock.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

36 lines
895 B
JavaScript
Executable file

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
/* exported
AdapterMock
*/
var AdapterMock = (action, args) => {
return {
update(kintoColl, options) {
AdapterMock.options = options;
if (action === 'noop') {
// Even if the adapter makes changes, we want to see that
// SyncEngine does not sync those changes up if the adapter
// return false.
return kintoColl.update.apply(kintoColl, args).then(() => {
return false;
});
}
if (action) {
return kintoColl[action].apply(kintoColl, args).then(() => {
return true;
});
}
return Promise.resolve(false);
},
handleConflict(conflict) {
return Promise.resolve(conflict.local);
},
reset() {
return Promise.resolve();
}
};
};