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

60 lines
1.4 KiB
JavaScript
Executable file

'use strict';
/* exported MockContacts */
var MockContacts = {
// We need to test calls without contact information
// so we'll return that info depending on the
// calling number
// '111': No contacts
// '222': More than 1 contact for that number
// Any other: 1 contact
findByNumber: function findByNumber(number, callback) {
this.mCalledWith = number;
this.mPhoto = 'test';
this.mName = 'test name';
var tel = {
value: this.mCalledWith,
carrier: this.mCarrier,
type: this.mType
};
var contact = {
id: this.mId,
name: [this.mName],
tel: [tel],
photo: [this.mPhoto]
};
var contactsWithSameNumber = 0;
switch (number) {
case '111':
this.mPhoto = null;
this.mName = null;
contact = null;
tel = null;
break;
case '222':
contactsWithSameNumber = 2;
break;
default:
}
callback(contact, tel, contactsWithSameNumber);
},
findListByNumber: function cm_getContactData(number, maxitems, callback) {
callback(this.mResult);
},
getRevision: function cm_getRevision(callback) { callback(0); },
mId: 'id',
mPhoto: null,
mName: null,
mCalledWith: null,
mCarrier: 'carrier',
mType: 'type',
mResult: null,
mTearDown: function tearDown() {
this._calledWith = null;
this.mCarrier = 'carrier';
this.mType = 'type';
this.mResult = [];
}
};