mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1401590 - Mock FxAccounts#newAccountState in push service tests. r=markh
MozReview-Commit-ID: 8kVtWbPKp65 --HG-- extra : rebase_source : cb970e68e7be85ea53723207b91c7981b84d41a4
This commit is contained in:
parent
4efc440d90
commit
27eb845182
@ -187,11 +187,20 @@ add_task(async function observePushTopicDeviceDisconnected_current_device() {
|
||||
}
|
||||
};
|
||||
|
||||
let signoutCalled = false;
|
||||
let { FxAccounts } = Cu.import("resource://gre/modules/FxAccounts.jsm", {});
|
||||
const fxAccountsMock = new FxAccounts({});
|
||||
fxAccountsMock.internal.currentAccountState.getUserAccountData = async () => {
|
||||
return { deviceId };
|
||||
};
|
||||
const fxAccountsMock = new FxAccounts({
|
||||
newAccountState() {
|
||||
return {
|
||||
async getUserAccountData() {
|
||||
return { deviceId };
|
||||
}
|
||||
}
|
||||
},
|
||||
signOut() {
|
||||
signoutCalled = true;
|
||||
}
|
||||
});
|
||||
|
||||
const deviceDisconnectedNotificationObserved = new Promise(resolve => {
|
||||
Services.obs.addObserver(function obs(subject, topic, data) {
|
||||
@ -209,6 +218,7 @@ add_task(async function observePushTopicDeviceDisconnected_current_device() {
|
||||
pushService.observe(msg, mockPushService.pushTopic, FXA_PUSH_SCOPE_ACCOUNT_UPDATE);
|
||||
|
||||
await deviceDisconnectedNotificationObserved;
|
||||
ok(signoutCalled);
|
||||
});
|
||||
|
||||
add_task(async function observePushTopicDeviceDisconnected_another_device() {
|
||||
@ -227,11 +237,20 @@ add_task(async function observePushTopicDeviceDisconnected_another_device() {
|
||||
}
|
||||
};
|
||||
|
||||
let signoutCalled = false;
|
||||
let { FxAccounts } = Cu.import("resource://gre/modules/FxAccounts.jsm", {});
|
||||
const fxAccountsMock = new FxAccounts({});
|
||||
fxAccountsMock.internal.currentAccountState.getUserAccountData = async () => {
|
||||
return { deviceId: "thelocaldevice" };
|
||||
};
|
||||
const fxAccountsMock = new FxAccounts({
|
||||
newAccountState() {
|
||||
return {
|
||||
async getUserAccountData() {
|
||||
return { deviceId: "thelocaldevice" };
|
||||
}
|
||||
}
|
||||
},
|
||||
signOut() {
|
||||
signoutCalled = true;
|
||||
}
|
||||
});
|
||||
|
||||
const deviceDisconnectedNotificationObserved = new Promise(resolve => {
|
||||
Services.obs.addObserver(function obs(subject, topic, data) {
|
||||
@ -249,6 +268,7 @@ add_task(async function observePushTopicDeviceDisconnected_another_device() {
|
||||
pushService.observe(msg, mockPushService.pushTopic, FXA_PUSH_SCOPE_ACCOUNT_UPDATE);
|
||||
|
||||
await deviceDisconnectedNotificationObserved;
|
||||
ok(!signoutCalled);
|
||||
});
|
||||
|
||||
add_test(function observePushTopicAccountDestroyed() {
|
||||
|
Loading…
Reference in New Issue
Block a user