VulpesOS/gaia/shared/test/unit/mocks/mock_vcard_parser.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

35 lines
795 B
JavaScript
Executable file

'use strict';
/* exports MockVcardParser */
/* exports MockVCFReader */
function MockVcardParser(textToParse) {
this.text = textToParse;
}
MockVcardParser.prototype.process = function process(cb) {
cb();
};
function MockVCFReader(textToParse) {
this.text = textToParse;
}
MockVCFReader.prototype.process = function process(cb) {
var importedContacts = [];
if (this.onerror && this.text == 'error') {
this.onerror({ message: 'error importing'});
} else {
var count = this.text.match(/END:VCARD/g).length;
if (this.onimported) {
for (var i = 0; i < count; i++) {
this.onimported();
importedContacts.push({id: (i + 1)});
}
if (this.onread) {
this.onread(count);
}
}
}
cb(importedContacts, this.numDuplicated);
};