|
| 1 | +/** |
| 2 | + * @file Unit Tests - OptionEvent |
| 3 | + * @module kronk/events/tests/unit/OptionEvent |
| 4 | + */ |
| 5 | + |
| 6 | +import optionValueSource from '#enums/option-value-source' |
| 7 | +import KronkEvent from '#events/kronk.event' |
| 8 | +import TestSubject from '#events/option.event' |
| 9 | +import Option from '#lib/option' |
| 10 | +import type { |
| 11 | + Flags, |
| 12 | + OptionValueSource, |
| 13 | + RawOptionValue |
| 14 | +} from '@flex-development/kronk' |
| 15 | +import { ok } from 'devlop' |
| 16 | + |
| 17 | +describe('unit:events/OptionEvent', () => { |
| 18 | + let flag: Flags |
| 19 | + let option: Option |
| 20 | + let source: OptionValueSource |
| 21 | + let subject: TestSubject |
| 22 | + let value: RawOptionValue |
| 23 | + |
| 24 | + beforeAll(() => { |
| 25 | + option = new Option('-d | --debug') |
| 26 | + ok(typeof option.long === 'string', 'expected `option.long`') |
| 27 | + |
| 28 | + flag = option.long |
| 29 | + source = optionValueSource.config |
| 30 | + value = true |
| 31 | + |
| 32 | + subject = new TestSubject(option, value, source, flag) |
| 33 | + }) |
| 34 | + |
| 35 | + describe('constructor', () => { |
| 36 | + it('should be instanceof `KronkEvent`', () => { |
| 37 | + expect(subject).to.be.instanceof(KronkEvent) |
| 38 | + }) |
| 39 | + |
| 40 | + it('should set #flag', () => { |
| 41 | + expect(subject).to.have.property('flag', flag) |
| 42 | + }) |
| 43 | + |
| 44 | + it('should set #id', () => { |
| 45 | + expect(subject).to.have.property('id', option.event) |
| 46 | + }) |
| 47 | + |
| 48 | + it('should set #option', () => { |
| 49 | + expect(subject).to.have.property('option', option) |
| 50 | + }) |
| 51 | + |
| 52 | + it('should set #source', () => { |
| 53 | + expect(subject).to.have.property('source', source) |
| 54 | + }) |
| 55 | + |
| 56 | + it('should set #value', () => { |
| 57 | + expect(subject).to.have.property('value', value) |
| 58 | + }) |
| 59 | + }) |
| 60 | +}) |
0 commit comments