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({
|
const vm = new RootViewModel({
|
||||||
request: xhrRequest,
|
request: xhrRequest,
|
||||||
openLink: url => location.href = url,
|
openLink: url => location.href = url,
|
||||||
|
setTimeout: (f, time) => window.setTimeout(f, time),
|
||||||
platforms: guessApplicablePlatforms(navigator.userAgent, navigator.platform),
|
platforms: guessApplicablePlatforms(navigator.userAgent, navigator.platform),
|
||||||
preferences: new Preferences(window.localStorage),
|
preferences: new Preferences(window.localStorage),
|
||||||
origin: location.origin,
|
origin: location.origin,
|
||||||
|
|
|
@ -45,7 +45,7 @@ export class OpenLinkViewModel extends ViewModel {
|
||||||
const matrixUrl = this._link.toMatrixUrl()
|
const matrixUrl = this._link.toMatrixUrl()
|
||||||
if (matrixUrl) {
|
if (matrixUrl) {
|
||||||
this.tryingLink = true;
|
this.tryingLink = true;
|
||||||
setTimeout(() => {
|
this.setTimeout(() => {
|
||||||
this.tryingLink = false;
|
this.tryingLink = false;
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
@ -63,6 +63,7 @@ export class ViewModel extends EventEmitter {
|
||||||
get request() { return this._options.request; }
|
get request() { return this._options.request; }
|
||||||
get origin() { return this._options.origin; }
|
get origin() { return this._options.origin; }
|
||||||
get openLink() { return this._options.openLink; }
|
get openLink() { return this._options.openLink; }
|
||||||
|
get setTimeout() { return this._options.setTimeout; }
|
||||||
get platforms() { return this._options.platforms; }
|
get platforms() { return this._options.platforms; }
|
||||||
get preferences() { return this._options.preferences; }
|
get preferences() { return this._options.preferences; }
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ export class ViewModel extends EventEmitter {
|
||||||
request: this.request,
|
request: this.request,
|
||||||
origin: this.origin,
|
origin: this.origin,
|
||||||
openLink: this.openLink,
|
openLink: this.openLink,
|
||||||
|
setTimeout: this.setTimeout,
|
||||||
platforms: this.platforms,
|
platforms: this.platforms,
|
||||||
preferences: this.preferences,
|
preferences: this.preferences,
|
||||||
}, options);
|
}, options);
|
||||||
|
|
Loading…
Reference in a new issue