-
Notifications
You must be signed in to change notification settings - Fork 269
/
link-paths-spec.js
32 lines (27 loc) · 1.06 KB
/
link-paths-spec.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
"use babel"
import linkPaths from "../lib/link-paths"
describe("linkPaths", () => {
it("detects file paths with line numbers", () => {
const result = linkPaths("foo() b/c.js:44:55")
expect(result).toContain("foo() <a")
expect(result).toContain('class="-linked-path"')
expect(result).toContain('data-path="b/c.js"')
expect(result).toContain('data-line="44"')
expect(result).toContain('data-column="55"')
expect(result).toContain("b/c.js:44:55")
})
it("detects file paths with Windows style drive prefix", () => {
const result = linkPaths("foo() C:/b/c.js:44:55")
expect(result).toContain('data-path="C:/b/c.js"')
})
it("allow ommitting the column number", () => {
const result = linkPaths("foo() b/c.js:44")
expect(result).toContain('data-line="44"')
expect(result).toContain('data-column=""')
})
it("links multiple paths", () => {
const multilineResult = linkPaths("foo() b/c.js:44:5\nbar() b/c.js:45:56")
expect(multilineResult).toContain("foo() <a")
expect(multilineResult).toContain("bar() <a")
})
})