« get me outta code hell

test: general refactor instantiating things & managing wikiData - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/things/flash.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-08-05 20:39:44 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-08-05 20:42:09 -0300
commit91469b51fe10fbedaece83dafb07e1fd6730e11c (patch)
tree22a0b2e82f891ce4f0f4c5309be2166190aabe2e /test/unit/data/things/flash.js
parent4cb5d1d0c231afad0175b2824320d0612f0eceef (diff)
test: general refactor instantiating things & managing wikiData
Diffstat (limited to 'test/unit/data/things/flash.js')
-rw-r--r--test/unit/data/things/flash.js39
1 files changed, 12 insertions, 27 deletions
diff --git a/test/unit/data/things/flash.js b/test/unit/data/things/flash.js
index 62059604..de39e80d 100644
--- a/test/unit/data/things/flash.js
+++ b/test/unit/data/things/flash.js
@@ -1,39 +1,24 @@
 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;
-}
+import {
+  linkAndBindWikiData,
+  stubThing,
+  stubWikiData,
+} from '#test-lib';
 
 t.test(`Flash.color`, t => {
+  const {Flash, FlashAct} = thingConstructors;
+
   t.plan(4);
 
-  const flash = stubFlash();
-  const flashAct = stubFlashAct([flash]);
+  const wikiData = stubWikiData();
+
+  const flash = stubThing(wikiData, Flash, {directory: 'my-flash'});
+  const flashAct = stubThing(wikiData, FlashAct, {flashes: ['flash:my-flash']});
 
-  const {XXX_decacheWikiData} = linkAndBindWikiData({
-    flashData: [flash],
-    flashActData: [flashAct],
-  });
+  const {XXX_decacheWikiData} = linkAndBindWikiData(wikiData);
 
   t.equal(flash.color, null,
     `color #1: defaults to null`);