aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/modules/diff-file.test.ts
blob: f0438538a006b5fb71630d858dae8a6bf4824baa (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {diffTreeStoreSetViewed, reactiveDiffTreeStore} from './diff-file.ts';

test('diff-tree', () => {
  const store = reactiveDiffTreeStore({
    'TreeRoot': {
      'FullName': '',
      'DisplayName': '',
      'EntryMode': '',
      'IsViewed': false,
      'NameHash': '....',
      'DiffStatus': '',
      'FileIcon': '',
      'Children': [
        {
          'FullName': 'dir1',
          'DisplayName': 'dir1',
          'EntryMode': 'tree',
          'IsViewed': false,
          'NameHash': '....',
          'DiffStatus': '',
          'FileIcon': '',
          'Children': [
            {
              'FullName': 'dir1/test.txt',
              'DisplayName': 'test.txt',
              'DiffStatus': 'added',
              'NameHash': '....',
              'EntryMode': '',
              'IsViewed': false,
              'FileIcon': '',
              'Children': null,
            },
          ],
        },
        {
          'FullName': 'other.txt',
          'DisplayName': 'other.txt',
          'NameHash': '........',
          'DiffStatus': 'added',
          'EntryMode': '',
          'IsViewed': false,
          'FileIcon': '',
          'Children': null,
        },
      ],
    },
  }, '', '');
  diffTreeStoreSetViewed(store, 'dir1/test.txt', true);
  expect(store.fullNameMap['dir1/test.txt'].IsViewed).toBe(true);
  expect(store.fullNameMap['dir1'].IsViewed).toBe(true);
});