File size: 2,777 Bytes
87b3b3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
describe("Display", function() {
	describe("drawText", function() {
		it("should provide default maxWidth", function() {
			var d = new ROT.Display({width:10, height:10});
			var lines = d.drawText(7, 0, "aaaaaa");
			expect(lines).toBe(2);
		});
	});

	describe("computeSize", function() {
		describe("rectangular layout", function() {
			var d1 = new ROT.Display({fontSize:18, spacing:1});
			var d2 = new ROT.Display({fontSize:18, spacing:1.2});

			it("should compute integer size for spacing 1", function() {
				var size = d1.computeSize(1/0, 180);
				expect(size[1]).toBe(10);
			});

			it("should compute fractional size for spacing 1", function() {
				var size = d1.computeSize(1/0, 170);
				expect(size[1]).toBe(9);
			});

			it("should compute integer size for spacing >1", function() {
				var size = d2.computeSize(1/0, 220);
				expect(size[1]).toBe(10);
			});

			it("should compute fractional size for spacing >1", function() {
				var size = d2.computeSize(1/0, 210);
				expect(size[1]).toBe(9);
			});
		});

		describe("hex layout", function() {
			var d1 = new ROT.Display({fontSize:18, spacing:1, layout:"hex"});
			var d2 = new ROT.Display({fontSize:18, spacing:1.2, layout:"hex"});

			it("should compute size for spacing 1", function() {
				var size = d1.computeSize(1/0, 96);
				expect(size[1]).toBe(5);
			});

			it("should compute size for spacing >1", function() {
				var size = d2.computeSize(1/0, 96);
				expect(size[1]).toBe(4);
			});
		});
	});

	describe("computeFontSize", function() {
		describe("rectangular layout", function() {
			var d1 = new ROT.Display({width:100, height:20, spacing:1});
			var d2 = new ROT.Display({width:100, height:20, spacing:1.2});

			it("should compute integer size for spacing 1", function() {
				var size = d1.computeFontSize(1/0, 180);
				expect(size).toBe(9);
			});

			it("should compute fractional size for spacing 1", function() {
				var size = d1.computeFontSize(1/0, 170);
				expect(size).toBe(8);
			});

			it("should compute integer size for spacing >1", function() {
				var size = d2.computeFontSize(1/0, 180);
				expect(size).toBe(7);
			});

			it("should compute fractional size for spacing >1", function() {
				var size = d2.computeFontSize(1/0, 170);
				expect(size).toBe(6);
			});
		});

		describe("hex layout", function() {
			var d1 = new ROT.Display({width:100, height:5, spacing:1, layout:"hex"});
			var d2 = new ROT.Display({width:100, height:5, spacing:1.3, layout:"hex"});

			xit("should compute size for spacing 1", function() {
				var size = d1.computeFontSize(1/0, 96);
				expect(size).toBe(18);
			});

			it("should compute size for spacing >1", function() {
				var size = d2.computeFontSize(1/0, 96);
				expect(size).toBe(14);
			});
		});
	});
});