diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts index 8aabb8adf..e70f7f9be 100644 --- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts +++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts @@ -13,11 +13,11 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { useTalerActionURL } from "./useTalerActionURL.js"; -import { mountHook } from "../test-utils.js"; -import { IoCProviderForTesting } from "../context/iocContext.js"; -import { h, VNode } from "preact"; import { expect } from "chai"; +import { h, VNode } from "preact"; +import { IoCProviderForTesting } from "../context/iocContext.js"; +import { useTalerActionURL } from "./useTalerActionURL.js"; +import { tests } from "@gnu-taler/web-util/lib/index.browser"; describe("useTalerActionURL hook", () => { it("should be set url to undefined when dismiss", async () => { @@ -31,32 +31,28 @@ describe("useTalerActionURL hook", () => { }); }; - const { pullLastResultOrThrow, waitForStateUpdate, assertNoPendingUpdate } = - mountHook(useTalerActionURL, ctx); - - { - const [url] = pullLastResultOrThrow(); - expect(url).undefined; - } - - expect(await waitForStateUpdate()).true; - - { - const [url, setDismissed] = pullLastResultOrThrow(); - expect(url).deep.equals({ - location: "clipboard", - uri: "qwe", - }); - setDismissed(true); - } - - expect(await waitForStateUpdate()).true; + const hookBehavior = await tests.hookBehaveLikeThis( + useTalerActionURL, + {}, + [ + ([url]) => { + expect(url).undefined; + }, + ([url, setDismissed]) => { + expect(url).deep.equals({ + location: "clipboard", + uri: "qwe", + }); + setDismissed(true); + }, + ([url]) => { + if (url !== undefined) throw Error("invalid"); + expect(url).undefined; + }, + ], + ctx, + ); - { - const [url] = pullLastResultOrThrow(); - if (url !== undefined) throw Error("invalid"); - expect(url).undefined; - } - await assertNoPendingUpdate(); + expect(hookBehavior).deep.equal({ result: "ok" }); }); }); |