-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoordinateParser_spec.js
48 lines (34 loc) · 1.22 KB
/
CoordinateParser_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict'
var CoordinateParser = require("./CoordinateParser");
describe("Coordinate parser", function(){
it("should understand a single digit", function(){
var result = CoordinateParser.parse("1");
expect(result.x).toBe("1");
expect(result.y).toBe(undefined);
});
it("should understand two single digits", function(){
var result = CoordinateParser.parse("2 3");
expect(result.x).toBe("2");
expect(result.y).toBe("3");
});
it("should understand more than one digit", function(){
var result = CoordinateParser.parse("202 389");
expect(result.x).toBe("202");
expect(result.y).toBe("389");
});
it("should accept a max limit coordinates based on a boundary", function(){
var result = CoordinateParser.parse("20 21", 20);
expect(result.x).toBe("20");
expect(result.y).toBe(undefined);
});
it("should fix zero to undefined", function(){
var result = CoordinateParser.parse("0 0");
expect(result.x).toBe(undefined);
expect(result.y).toBe(undefined);
});
it("should not break on empty space input", function(){
var result = CoordinateParser.parse("");
expect(result.x).toBe(undefined);
expect(result.y).toBe(undefined);
});
});