1 import type { ItemRevision } from '@proton/pass/types';
3 import { isBreached, isDisabledAlias, isHealthCheckSkipped, isMonitored } from './item.predicates';
5 describe('item predicates', () => {
6 test('`isMonitored`', () => {
7 expect(isMonitored({ flags: parseInt('000', 2) } as ItemRevision)).toBe(true);
8 expect(isMonitored({ flags: parseInt('010', 2) } as ItemRevision)).toBe(true);
9 expect(isMonitored({ flags: parseInt('110', 2) } as ItemRevision)).toBe(true);
10 expect(isMonitored({ flags: parseInt('100', 2) } as ItemRevision)).toBe(true);
11 expect(isMonitored({ flags: parseInt('001', 2) } as ItemRevision)).toBe(false);
12 expect(isMonitored({ flags: parseInt('011', 2) } as ItemRevision)).toBe(false);
13 expect(isMonitored({ flags: parseInt('101', 2) } as ItemRevision)).toBe(false);
14 expect(isMonitored({ flags: parseInt('111', 2) } as ItemRevision)).toBe(false);
17 test('`isHealthCheckSkipped`', () => {
18 expect(isHealthCheckSkipped({ flags: parseInt('000', 2) } as ItemRevision)).toBe(false);
19 expect(isHealthCheckSkipped({ flags: parseInt('010', 2) } as ItemRevision)).toBe(false);
20 expect(isHealthCheckSkipped({ flags: parseInt('110', 2) } as ItemRevision)).toBe(false);
21 expect(isHealthCheckSkipped({ flags: parseInt('100', 2) } as ItemRevision)).toBe(false);
22 expect(isHealthCheckSkipped({ flags: parseInt('001', 2) } as ItemRevision)).toBe(true);
23 expect(isHealthCheckSkipped({ flags: parseInt('011', 2) } as ItemRevision)).toBe(true);
24 expect(isHealthCheckSkipped({ flags: parseInt('101', 2) } as ItemRevision)).toBe(true);
25 expect(isHealthCheckSkipped({ flags: parseInt('111', 2) } as ItemRevision)).toBe(true);
28 test('`isBreached`', () => {
29 expect(isBreached({ flags: parseInt('000', 2) } as ItemRevision)).toBe(false);
30 expect(isBreached({ flags: parseInt('010', 2) } as ItemRevision)).toBe(true);
31 expect(isBreached({ flags: parseInt('110', 2) } as ItemRevision)).toBe(true);
32 expect(isBreached({ flags: parseInt('100', 2) } as ItemRevision)).toBe(false);
33 expect(isBreached({ flags: parseInt('001', 2) } as ItemRevision)).toBe(false);
34 expect(isBreached({ flags: parseInt('011', 2) } as ItemRevision)).toBe(true);
35 expect(isBreached({ flags: parseInt('101', 2) } as ItemRevision)).toBe(false);
36 expect(isBreached({ flags: parseInt('111', 2) } as ItemRevision)).toBe(true);
39 test('`isAliasDisabled`', () => {
40 expect(isDisabledAlias({ flags: parseInt('000', 2) } as ItemRevision)).toBe(false);
41 expect(isDisabledAlias({ flags: parseInt('010', 2) } as ItemRevision)).toBe(false);
42 expect(isDisabledAlias({ flags: parseInt('110', 2) } as ItemRevision)).toBe(true);
43 expect(isDisabledAlias({ flags: parseInt('100', 2) } as ItemRevision)).toBe(true);
44 expect(isDisabledAlias({ flags: parseInt('001', 2) } as ItemRevision)).toBe(false);
45 expect(isDisabledAlias({ flags: parseInt('011', 2) } as ItemRevision)).toBe(false);
46 expect(isDisabledAlias({ flags: parseInt('101', 2) } as ItemRevision)).toBe(true);
47 expect(isDisabledAlias({ flags: parseInt('111', 2) } as ItemRevision)).toBe(true);