« get me outta code hell

flash.js « things « data « unit « test - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/things/flash.js
blob: de39e80de12935414ea51a940bbbda8ff0302f85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import t from 'tap';

import thingConstructors from '#things';

import {
  linkAndBindWikiData,
  stubThing,
  stubWikiData,
} from '#test-lib';

t.test(`Flash.color`, t => {
  const {Flash, FlashAct} = thingConstructors;

  t.plan(4);

  const wikiData = stubWikiData();

  const flash = stubThing(wikiData, Flash, {directory: 'my-flash'});
  const flashAct = stubThing(wikiData, FlashAct, {flashes: ['flash:my-flash']});

  const {XXX_decacheWikiData} = linkAndBindWikiData(wikiData);

  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`);
});