aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/services/theme_data/theme_data3.spec.js
blob: 37d343f9fedf79fcd119a0f7bd8574fa774c4d0a (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// import { topoSort } from 'src/services/theme_data/theme_data.service.js'
import {
  getAllPossibleCombinations
} from 'src/services/theme_data/iss_utils.js'
import {
  init
} from 'src/services/theme_data/theme_data_3.service.js'
import {
  basePaletteKeys
} from 'src/services/theme_data/theme2_to_theme3.js'

describe.only('Theme Data 3', () => {
  describe('getAllPossibleCombinations', () => {
    it('test simple 3 values case', () => {
      const out = getAllPossibleCombinations([1, 2, 3]).map(x => x.sort((a, b) => a - b))
      expect(out).to.eql([
        [1], [2], [3],
        [1, 2], [1, 3], [2, 3],
        [1, 2, 3]
      ])
    })

    it('test simple 4 values case', () => {
      const out = getAllPossibleCombinations([1, 2, 3, 4]).map(x => x.sort((a, b) => a - b))
      expect(out).to.eql([
        [1], [2], [3], [4],
        [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4],
        [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4],
        [1, 2, 3, 4]
      ])
    })
  })

  describe('init', () => {
    it('Test initialization without anything', () => {
      const out = init([], '#DEADAF')

      expect(out).to.have.property('eager')
      expect(out).to.have.property('lazy')
      expect(out).to.have.property('staticVars')

      expect(out.lazy).to.be.an('array')
      expect(out.lazy).to.have.lengthOf.above(1)
      expect(out.eager).to.be.an('array')
      expect(out.eager).to.have.lengthOf.above(1)
      expect(out.staticVars).to.be.an('object')

      // check backwards compat/generic stuff
      basePaletteKeys.forEach(key => {
        expect(out.staticVars).to.have.property(key)
      })
    })
  })
})