Receive setTimeout as argument to help mocking
This commit is contained in:
parent
c26b8dcec1
commit
b8e07cda7e
3 changed files with 4 additions and 1 deletions
|
@ -24,6 +24,7 @@ export async function main(container) {
|
|||
const vm = new RootViewModel({
|
||||
request: xhrRequest,
|
||||
openLink: url => location.href = url,
|
||||
setTimeout: (f, time) => window.setTimeout(f, time),
|
||||
platforms: guessApplicablePlatforms(navigator.userAgent, navigator.platform),
|
||||
preferences: new Preferences(window.localStorage),
|
||||
origin: location.origin,
|
||||
|
|
|
@ -45,7 +45,7 @@ export class OpenLinkViewModel extends ViewModel {
|
|||
const matrixUrl = this._link.toMatrixUrl()
|
||||
if (matrixUrl) {
|
||||
this.tryingLink = true;
|
||||
setTimeout(() => {
|
||||
this.setTimeout(() => {
|
||||
this.tryingLink = false;
|
||||
this.emitChange();
|
||||
}, 1000);
|
||||
|
|
|
@ -63,6 +63,7 @@ export class ViewModel extends EventEmitter {
|
|||
get request() { return this._options.request; }
|
||||
get origin() { return this._options.origin; }
|
||||
get openLink() { return this._options.openLink; }
|
||||
get setTimeout() { return this._options.setTimeout; }
|
||||
get platforms() { return this._options.platforms; }
|
||||
get preferences() { return this._options.preferences; }
|
||||
|
||||
|
@ -71,6 +72,7 @@ export class ViewModel extends EventEmitter {
|
|||
request: this.request,
|
||||
origin: this.origin,
|
||||
openLink: this.openLink,
|
||||
setTimeout: this.setTimeout,
|
||||
platforms: this.platforms,
|
||||
preferences: this.preferences,
|
||||
}, options);
|
||||
|
|
Loading…
Reference in a new issue