|
| 1 | +import { Slot } from '../../src/componentSlots' |
| 2 | +import { createSlots } from '../../src/helpers/createSlots' |
| 3 | + |
| 4 | +describe('createSlot', () => { |
| 5 | + const slot = () => [] |
| 6 | + let record: Record<string, Slot> |
| 7 | + |
| 8 | + beforeEach(() => { |
| 9 | + record = {} |
| 10 | + }) |
| 11 | + |
| 12 | + it('should return a slot', () => { |
| 13 | + const dynamicSlot = [{ name: 'descriptor', fn: slot }] |
| 14 | + |
| 15 | + const actual = createSlots(record, dynamicSlot) |
| 16 | + |
| 17 | + expect(actual).toEqual({ descriptor: slot }) |
| 18 | + }) |
| 19 | + |
| 20 | + it('should add all slots to the record', () => { |
| 21 | + const dynamicSlot = [ |
| 22 | + { name: 'descriptor', fn: slot }, |
| 23 | + { name: 'descriptor2', fn: slot } |
| 24 | + ] |
| 25 | + |
| 26 | + const actual = createSlots(record, dynamicSlot) |
| 27 | + |
| 28 | + expect(actual).toEqual({ descriptor: slot, descriptor2: slot }) |
| 29 | + }) |
| 30 | + |
| 31 | + it('should add slot to the record when given slot is an array', () => { |
| 32 | + const dynamicSlot = [ |
| 33 | + { name: 'descriptor', fn: slot }, |
| 34 | + [{ name: 'descriptor2', fn: slot }] |
| 35 | + ] |
| 36 | + |
| 37 | + const actual = createSlots(record, dynamicSlot) |
| 38 | + |
| 39 | + expect(actual).toEqual({ descriptor: slot, descriptor2: slot }) |
| 40 | + }) |
| 41 | + |
| 42 | + it('should add each slot to the record when given slot is an array', () => { |
| 43 | + const dynamicSlot = [ |
| 44 | + { name: 'descriptor', fn: slot }, |
| 45 | + [{ name: 'descriptor2', fn: slot }, { name: 'descriptor3', fn: slot }] |
| 46 | + ] |
| 47 | + |
| 48 | + const actual = createSlots(record, dynamicSlot) |
| 49 | + |
| 50 | + expect(actual).toEqual({ |
| 51 | + descriptor: slot, |
| 52 | + descriptor2: slot, |
| 53 | + descriptor3: slot |
| 54 | + }) |
| 55 | + }) |
| 56 | +}) |
0 commit comments