Skip to content

Commit 8cb1708

Browse files
committed
Add test for location, add istanbul.yml
1 parent 5565bfd commit 8cb1708

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ ENV
55
.elasticbeanstalk/*
66
!.elasticbeanstalk/*.cfg.yml
77
!.elasticbeanstalk/*.global.yml
8+
coverage/

.istanbul.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
instrumentation:
2+
excludes:
3+
- src/parser/Errors.js
4+
- parser/Errors.js
5+

src/util/__tests__/location-test.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
jest.disableAutomock();
2+
3+
import { Position, SourceLocation } from '../location';
4+
5+
describe('Position', () => {
6+
const line = 10;
7+
const column = 5;
8+
9+
it('creates a new instance with line and column set', () => {
10+
const p = new Position(line, column);
11+
expect(p instanceof Position).toBe(true);
12+
13+
expect(p.line).toBe(line);
14+
expect(p.column).toBe(column);
15+
});
16+
17+
it('clones the instance', () => {
18+
const p = new Position(line, column);
19+
const c = p.clone();
20+
21+
expect(p).toEqual(c);
22+
expect(p).not.toBe(c);
23+
});
24+
});
25+
26+
describe('SourceLocation', () => {
27+
const start = new Position(0, 0);
28+
const end = new Position(10, 50);
29+
30+
it('creates a new instance with start and end set', () => {
31+
const loc = new SourceLocation(start, end);
32+
expect(loc instanceof SourceLocation).toBe(true);
33+
34+
expect(loc.start).toBe(start);
35+
expect(loc.end).toBe(end);
36+
});
37+
38+
it('clones the instance and the position', () => {
39+
const loc = new SourceLocation(start, end);
40+
const c = loc.clone();
41+
42+
expect(loc).toEqual(c);
43+
expect(loc).not.toBe(c);
44+
expect(c.start).not.toBe(start);
45+
expect(c.end).not.toBe(end);
46+
});
47+
});

0 commit comments

Comments
 (0)