From 0dfa36a3b6b95d791f37681e98e256c46aa55ae8 Mon Sep 17 00:00:00 2001 From: Eddie Antonio Santos Date: Mon, 19 Nov 2018 18:35:58 -0700 Subject: [PATCH] Attempt to clarify comment on LMLayerWorker.install(). --- common/predictive-text/worker/index.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common/predictive-text/worker/index.ts b/common/predictive-text/worker/index.ts index afc24bbfc3..2d5fc0c5da 100644 --- a/common/predictive-text/worker/index.ts +++ b/common/predictive-text/worker/index.ts @@ -86,9 +86,21 @@ class LMLayerWorker { } /** - * Creates a new instance of the LMLayerWorker, and installs - * all its functions within the provided Worker scope. - * + * Creates a new instance of the LMLayerWorker, and installs all its + * functions within the provided Worker global scope. + * + * In production, this is called within the Worker's scope as: + * + * LMLayerWorker.install(self); + * + * ...and this will setup onmessage and postMessage() appropriately. + * + * During testing, this method is useful to mock an entire global scope, + * + * var fakeScope = { postMessage: ... }; + * LMLayerWorker.install(fakeScope); + * // now we can spy on methods in fakeScope! + * * @param scope A global scope to install upon. */ static install(scope: DedicatedWorkerGlobalScope): LMLayerWorker {