/
open-report.js
77 lines (68 loc) · 1.31 KB
/
open-report.js
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
72
73
74
75
76
77
import path from 'path';
import test from 'ava';
import fn from '../open-report';
const singleFileReportFixture = {
errorCount: 1,
results: [
{
errorCount: 1,
filePath: 'foo.js',
messages:[
{
line: 42,
column: 43
}
]
}
]
};
const singleSpawnMacro = (t, input, expected) => {
t.plan(3);
fn(input.report, {
editor: input.editor,
spawn: (cmd, args, opts) => {
t.is(cmd, expected.cmd);
t.deepEqual(args, expected.args);
return {
unref: () => {
t.pass();
}
}
}
});
}
test('VS Code - single file report', singleSpawnMacro, {
editor: 'code',
report: singleFileReportFixture
}, {
cmd: 'code',
args: ['--goto', 'foo.js:42:43']
});
test('Sublime Text - single file report', singleSpawnMacro, {
editor: 'subl',
report: singleFileReportFixture
}, {
cmd: 'subl',
args: ['foo.js:42:43']
});
test('Atom - single file report', singleSpawnMacro, {
editor: 'atom',
report: singleFileReportFixture
}, {
cmd: 'atom',
args: ['foo.js:42:43']
});
test('WebStorm - single file report', singleSpawnMacro, {
editor: 'wstorm',
report: singleFileReportFixture
}, {
cmd: 'wstorm',
args: ['foo.js:42']
});
test('TextMate - single file report', singleSpawnMacro, {
editor: 'mate',
report: singleFileReportFixture
}, {
cmd: 'mate',
args: ['--line', '42:43', 'foo.js']
});