« get me outta code hell

coverage-map.js - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/coverage-map.js
blob: beff9e8a0a0ab06939e125e8f66d8f94adbf54fa (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// node-tap test -> src coverage map
// https://node-tap.org/coverage/

export default function map(F) {
  let match;

  // unit/content/...

  match = F.match(/^test\/unit\/content\/(.*)$/);
  if (match) {
    const f = match[1];

    match = f.match(/^dependencies\/(.*)\.js$/);
    if (match) {
      return `src/content/dependencies/${match[1]}.js`;
    }
  }

  // unit/data/...

  match = F.match(/^test\/unit\/data\/(.*)$/);
  if (match) {
    const f = match[1];

    match = f.match(/^composite\/(.*)$/);
    if (match) {
      return `src/data/composite/${match[1]}`;
    }

    match = f.match(/^things\/(.*)\.js$/);
    if (match) {
      return `src/data/things/${match[1]}.js`;
    }

    match = f.match(/^cacheable-object\.js$/);
    if (match) {
      return `src/data/things/cacheable-object.js`;
    }

    match = f.match(/^(templateCompositeFrom|compositeFrom)\.js$/);
    if (match) {
      return `src/data/things/composite.js`;
    }
  }

  // unit/util/...

  match = F.match(/^test\/unit\/util\/(.*)$/);
  if (match) {
    const f = match[1];

    switch (f) {
      case 'html.js':
        return 'src/util/html.js';
    }
  }

  // snapshot/...

  match = F.match(/^test\/snapshot\/(.*)$/);
  if (match) {
    const f = match[1];

    match = f.match(/^(.*)\.js$/);
    if (match) {
      return `src/content/dependencies/${match[1]}.js`;
    }
  }

  return null;
}