From 91469b51fe10fbedaece83dafb07e1fd6730e11c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 5 Aug 2024 20:39:44 -0300 Subject: test: general refactor instantiating things & managing wikiData --- test/unit/data/things/flash.js | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'test/unit/data/things/flash.js') 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`); -- cgit 1.3.0-6-gf8a5