summaryrefslogtreecommitdiff
path: root/spec/frontend/set_status_modal/utils_spec.js
blob: a1c899be900408be7b94a2a2964ed3b6562130a5 (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
import { isUserBusy, computedClearStatusAfterValue } from '~/set_status_modal/utils';
import { AVAILABILITY_STATUS, NEVER_TIME_RANGE } from '~/set_status_modal/constants';
import { timeRanges } from '~/vue_shared/constants';

const [thirtyMinutes] = timeRanges;

describe('Set status modal utils', () => {
  describe('isUserBusy', () => {
    it.each`
      value                          | result
      ${''}                          | ${false}
      ${'fake status'}               | ${false}
      ${AVAILABILITY_STATUS.NOT_SET} | ${false}
      ${AVAILABILITY_STATUS.BUSY}    | ${true}
    `('with $value returns $result', ({ value, result }) => {
      expect(isUserBusy(value)).toBe(result);
    });
  });

  describe('computedClearStatusAfterValue', () => {
    it.each`
      value               | expected
      ${null}             | ${null}
      ${NEVER_TIME_RANGE} | ${null}
      ${thirtyMinutes}    | ${thirtyMinutes.shortcut}
    `('with $value returns $expected', ({ value, expected }) => {
      expect(computedClearStatusAfterValue(value)).toBe(expected);
    });
  });
});