From 2532ba76a87971a8d8041d689788d91ae13dc627 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 26 Oct 2023 17:13:02 -0300 Subject: test: Flash.color (unit) --- test/unit/data/things/flash.js | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/unit/data/things/flash.js (limited to 'test/unit/data') diff --git a/test/unit/data/things/flash.js b/test/unit/data/things/flash.js new file mode 100644 index 00000000..62059604 --- /dev/null +++ b/test/unit/data/things/flash.js @@ -0,0 +1,55 @@ +import t from 'tap'; + +import {linkAndBindWikiData} from '#test-lib'; +import thingConstructors from '#things'; + +const { + Flash, + FlashAct, + Thing, +} = thingConstructors; + +function stubFlash(directory = 'foo') { + const flash = new Flash(); + flash.directory = directory; + + return flash; +} + +function stubFlashAct(flashes, directory = 'bar') { + const flashAct = new FlashAct(); + flashAct.directory = directory; + flashAct.flashes = flashes.map(flash => Thing.getReference(flash)); + + return flashAct; +} + +t.test(`Flash.color`, t => { + t.plan(4); + + const flash = stubFlash(); + const flashAct = stubFlashAct([flash]); + + const {XXX_decacheWikiData} = linkAndBindWikiData({ + flashData: [flash], + flashActData: [flashAct], + }); + + t.equal(flash.color, null, + `color #1: defaults to null`); + + flashAct.color = '#abcdef'; + XXX_decacheWikiData(); + + t.equal(flash.color, '#abcdef', + `color #2: inherits from flash act`); + + flash.color = '#123456'; + + t.equal(flash.color, '#123456', + `color #3: is own value`); + + t.throws(() => { flash.color = '#aeiouw'; }, + {cause: TypeError}, + `color #4: must be set to valid color`); +}); -- cgit 1.3.0-6-gf8a5