Completed
Push — master ( 605e3d...3de0bb )
by Muhammad Dyas
14s queued 13s
created

tests/cards/schedule-close-poll-form.test.ts   A

Complexity

Total Complexity 8
Complexity/F 0

Size

Lines of Code 23
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 18
mnd 8
bc 8
fnc 0
dl 0
loc 23
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import ScheduleClosePollFormCard from '../../src/cards/ScheduleClosePollFormCard';
2
import {dummyAutoclosePollState, dummyLocalTimezone, dummyPollState} from '../dummy';
3
4
describe('ScheduleClosePollFormCard', () => {
5
  it('should crate form without any schedule time info', () => {
6
    const card = new ScheduleClosePollFormCard(dummyPollState, dummyLocalTimezone).create();
7
    expect(card.header.title).toBe('Schedule Close Poll');
8
    expect(card.header.subtitle).toBe('You can schedule the poll to close here.');
9
    // since not scheduled, the schedule info should undefined
10
    expect(card.sections!.find((section) => section.widgets?.[0]?.decoratedText?.startIcon?.knownIcon === 'CLOCK')).
11
      toBeUndefined();
12
    expect(JSON.stringify(card)).toContain('Create Schedule Close');
13
  });
14
  it('should crate form with correct state', () => {
15
    const card = new ScheduleClosePollFormCard(dummyAutoclosePollState, dummyLocalTimezone).create();
16
    const result = card.sections!.find(
17
      (section) => section.widgets?.[0]?.decoratedText?.startIcon?.knownIcon === 'CLOCK');
18
    expect(result).toBeDefined();
19
20
    expect(JSON.stringify(card)).toContain('Edit Schedule Close');
21
  });
22
});
23