From b68ad35094b03db7f81a20b881e2a6c1c1e8d143 Mon Sep 17 00:00:00 2001 From: nicholasrice Date: Sun, 12 May 2024 22:16:31 -0700 Subject: [PATCH] adding no-subscribe test case --- src/test/library.spec.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/library.spec.ts b/src/test/library.spec.ts index c44d9af..0d7f314 100644 --- a/src/test/library.spec.ts +++ b/src/test/library.spec.ts @@ -671,6 +671,36 @@ Extend( Assert.is(onChange.firstCall.args[0][1], extending.tokens.b, "b notified"); } ); +Extend( + "An extending library should not notify for tokens that are configured by the extending library", + async () => { + const config: Library.Config = { + a: { + type: DesignToken.Type.Color, + value: "#FFFFFF", + }, + b: { + type: DesignToken.Type.Color, + value: (context) => context.a, + }, + }; + const source = Library.create(config); + const extending = source.extend({ a: "#FFFFFF", b: "#000000" }); + const onChange = spy(); + const subscriber: Library.Subscriber = { + onChange, + }; + + extending.subscribe(subscriber); + + extending.tokens.b.value; // b needs to be accessed to set up watchers + extending.tokens.a.value; + source.tokens.a.set("#111111"); + + await nextUpdate(); + Assert.is(onChange.calledOnce, false); + } +); Description.run(); Lib.run();