Skip to content

Commit a043b47

Browse files
committed
Move the column specific pad calculator tests into separate files
1 parent 7280469 commit a043b47

4 files changed

Lines changed: 379 additions & 326 deletions

File tree

test/unitTests/padCalculation/contentPadCalculator.test.ts

Lines changed: 0 additions & 323 deletions
Original file line numberDiff line numberDiff line change
@@ -9,329 +9,6 @@ import { ColumnBasedPadCalculatorSelector } from '../../../src/padCalculation/co
99

1010
suite("ContentPadCalculator tests", () => {
1111

12-
test("getLeftPadding() First column not left padded", () => {
13-
const sut = createCalculator();
14-
const table = tableFor([
15-
[ "aaaaa", "bbbbb", "ccccc" ],
16-
[ "aaaaa", "bbbbb", "ccccc" ]
17-
]);
18-
19-
const pad = sut.getLeftPadding(table, 1, 0);
20-
21-
assert.equal(pad, "");
22-
});
23-
24-
test("getLeftPadding() First column left padded with 1 character if there is a left border", () => {
25-
const sut = createCalculator();
26-
const table = tableFor([
27-
[ "aaaaa", "bbbbb", "ccccc" ],
28-
[ "aaaaa", "bbbbb", "ccccc" ]
29-
]);
30-
table.hasLeftBorder = true;
31-
const pad = sut.getLeftPadding(table, 1, 1);
32-
33-
assert.equal(pad, " ");
34-
});
35-
36-
test("getLeftPadding() Middle column left padded with 1 character", () => {
37-
const sut = createCalculator();
38-
const table = tableFor([
39-
[ "aaaaa", "bbbbb", "ccccc" ],
40-
[ "aaaaa", "bbbbb", "ccccc" ]
41-
]);
42-
43-
const pad = sut.getLeftPadding(table, 1, 1);
44-
45-
assert.equal(pad, " ");
46-
});
47-
48-
test("getLeftPadding() Middle column is empty cell gets left padded with one character", () => {
49-
const sut = createCalculator();
50-
const table = tableFor([
51-
[ "aaa", "bbbb", "ccccc" ],
52-
[ "a", "", "c" ]
53-
]);
54-
55-
const pad = sut.getLeftPadding(table, 1, 1);
56-
57-
assert.equal(pad, " ");
58-
});
59-
60-
test("getLeftPadding() Last column left padded with 1 character", () => {
61-
const sut = createCalculator();
62-
const table = tableFor([
63-
[ "aaaaa", "bbbbb", "ccccc" ],
64-
[ "aaaaa", "bbbbb", "ccccc" ]
65-
]);
66-
67-
const pad = sut.getLeftPadding(table, 1, 2);
68-
69-
assert.equal(pad, " ");
70-
});
71-
72-
test("getRightPadding() First column equal to maxColLength gets right padded with one character", () => {
73-
const sut = createCalculator();
74-
const table = tableFor([
75-
[ "aaaaa", "bbbbb", "ccccc" ],
76-
[ "aaaaa", "bbbbb", "ccccc" ]
77-
]);
78-
79-
const pad = sut.getRightPadding(table, 1, 0);
80-
81-
assert.equal(pad, " ");
82-
});
83-
84-
test("getRightPadding() First column 1 char shorter than maxColLength gets right padded with 2 characters", () => {
85-
const sut = createCalculator();
86-
const table = tableFor([
87-
[ "aaaaa", "bbbbb", "ccccc" ],
88-
[ "aaaa", "bbbbb", "ccccc" ]
89-
]);
90-
91-
const pad = sut.getRightPadding(table, 1, 0);
92-
93-
assert.equal(pad, " ");
94-
});
95-
96-
test("getRightPadding() First column 2 char shorter than maxColLength gets right padded with 3 characters", () => {
97-
const sut = createCalculator();
98-
const table = tableFor([
99-
[ "aaaaa", "bbbbb", "ccccc" ],
100-
[ "aaa", "bbbbb", "ccccc" ]
101-
]);
102-
103-
const pad = sut.getRightPadding(table, 1, 0);
104-
105-
assert.equal(pad, " ");
106-
});
107-
108-
test("getRightPadding() First column 3 char shorter than maxColLength gets right padded with 4 characters", () => {
109-
const sut = createCalculator();
110-
const table = tableFor([
111-
[ "aaaaa", "bbbbb", "ccccc" ],
112-
[ "aa", "bbbbb", "ccccc" ]
113-
]);
114-
115-
const pad = sut.getRightPadding(table, 1, 0);
116-
117-
assert.equal(pad, " ");
118-
});
119-
120-
test("getRightPadding() First column 4 char shorter than maxColLength gets right padded with 5 characters", () => {
121-
const sut = createCalculator();
122-
const table = tableFor([
123-
[ "aaaaa", "bbbbb", "ccccc" ],
124-
[ "a", "bbbbb", "ccccc" ]
125-
]);
126-
127-
const pad = sut.getRightPadding(table, 1, 0);
128-
129-
assert.equal(pad, " ");
130-
});
131-
132-
test("getRightPadding() First column is empty string gets right padded with 5 characters", () => {
133-
const sut = createCalculator();
134-
const table = tableFor([
135-
[ "aaaaa", "bbbbb", "ccccc" ],
136-
[ "", "bbbbb", "ccccc" ]
137-
]);
138-
139-
const pad = sut.getRightPadding(table, 1, 0);
140-
141-
assert.equal(pad, " ");
142-
});
143-
144-
test("getRightPadding() Middle column is empty cell gets right padded with maxColLength-1 characters", () => {
145-
const sut = createCalculator();
146-
const table = tableFor([
147-
[ "aaaaa", "bbbbb", "ccccc" ],
148-
[ "aaaaa", "", "ccccc" ]
149-
]);
150-
151-
const pad = sut.getRightPadding(table, 1, 1);
152-
153-
assert.equal(pad, " ");
154-
});
155-
156-
test("getRightPadding() Middle column equal to maxColLength gets right padded with one character", () => {
157-
const sut = createCalculator();
158-
const table = tableFor([
159-
[ "aaaaa", "bbbbb", "ccccc" ],
160-
[ "aaaaa", "bbbbb", "ccccc" ]
161-
]);
162-
163-
const pad = sut.getRightPadding(table, 1, 1);
164-
165-
assert.equal(pad, " ");
166-
});
167-
168-
test("getRightPadding() Middle column 1 char shorter than maxColLength gets right padded with 2 characters", () => {
169-
const sut = createCalculator();
170-
const table = tableFor([
171-
[ "aaaaa", "bbbbb", "ccccc" ],
172-
[ "aaaaa", "bbbb", "ccccc" ]
173-
]);
174-
175-
const pad = sut.getRightPadding(table, 1, 1);
176-
177-
assert.equal(pad, " ");
178-
});
179-
180-
test("getRightPadding() Middle column 2 char shorter than maxColLength gets right padded with 3 characters", () => {
181-
const sut = createCalculator();
182-
const table = tableFor([
183-
[ "aaaaa", "bbbbb", "ccccc" ],
184-
[ "aaaaa", "bbb", "ccccc" ]
185-
]);
186-
187-
const pad = sut.getRightPadding(table, 1, 1);
188-
189-
assert.equal(pad, " ");
190-
});
191-
192-
test("getRightPadding() Middle column 3 char shorter than maxColLength gets right padded with 4 characters", () => {
193-
const sut = createCalculator();
194-
const table = tableFor([
195-
[ "aaaaa", "bbbbb", "ccccc" ],
196-
[ "aaaaa", "bb", "ccccc" ]
197-
]);
198-
199-
const pad = sut.getRightPadding(table, 1, 1);
200-
201-
assert.equal(pad, " ");
202-
});
203-
204-
test("getRightPadding() Middle column is empty string gets right padded with maxColLength characters", () => {
205-
const sut = createCalculator();
206-
const table = tableFor([
207-
[ "aaaaa", "bbbbb", "ccccc" ],
208-
[ "aaaaa", "", "ccccc" ]
209-
]);
210-
211-
const pad = sut.getRightPadding(table, 1, 1);
212-
213-
assert.equal(pad, " ");
214-
});
215-
216-
test("getRightPadding() Middle column with 0 maxLength gets right padded with 1 character", () => {
217-
const sut = createCalculator();
218-
const table = tableFor([
219-
[ "aaaaa", "", "ccccc" ],
220-
[ "aaaaa", "", "ccccc" ]
221-
]);
222-
223-
const pad = sut.getRightPadding(table, 1, 1);
224-
225-
assert.equal(pad, " ");
226-
});
227-
228-
test("getRightPadding() Last column not right padded if there's no border", () => {
229-
const sut = createCalculator();
230-
const table = tableFor([
231-
[ "aaaaa", "bbbbb", "ccccc" ],
232-
[ "aaaaa", "bbbbb", "c" ]
233-
]);
234-
235-
const pad = sut.getRightPadding(table, 1, 2);
236-
237-
assert.equal(pad, "");
238-
});
239-
240-
241-
242-
243-
test("getRightPadding() Last column equal to maxColLength gets right padded with one character if there is right border", () => {
244-
const sut = createCalculator();
245-
const table = tableFor([
246-
[ "aaaaa", "bbbbb", "ccccc" ],
247-
[ "aaaaa", "bbbbb", "ccccc" ]
248-
]);
249-
table.hasRightBorder = true;
250-
251-
const pad = sut.getRightPadding(table, 1, 2);
252-
253-
assert.equal(pad, " ");
254-
});
255-
256-
test("getRightPadding() Last column 1 char shorter than maxColLength gets right padded with 2 characters if there is right border", () => {
257-
const sut = createCalculator();
258-
const table = tableFor([
259-
[ "aaaaa", "bbbbb", "ccccc" ],
260-
[ "aaaaa", "bbbbb", "cccc" ]
261-
]);
262-
table.hasRightBorder = true;
263-
264-
const pad = sut.getRightPadding(table, 1, 2);
265-
266-
assert.equal(pad, " ");
267-
});
268-
269-
test("getRightPadding() Last column 2 chars shorter than maxColLength gets right padded with 3 characters if there is right border", () => {
270-
const sut = createCalculator();
271-
const table = tableFor([
272-
[ "aaaaa", "bbbbb", "ccccc" ],
273-
[ "aaaaa", "bbbbb", "ccc" ]
274-
]);
275-
table.hasRightBorder = true;
276-
277-
const pad = sut.getRightPadding(table, 1, 2);
278-
279-
assert.equal(pad, " ");
280-
});
281-
282-
test("getRightPadding() Last column 3 char shorter than maxColLength gets right padded with 4 characters if there is right border", () => {
283-
const sut = createCalculator();
284-
const table = tableFor([
285-
[ "aaaaa", "bbbbb", "ccccc" ],
286-
[ "aaaaa", "bbbbb", "cc" ]
287-
]);
288-
table.hasRightBorder = true;
289-
290-
const pad = sut.getRightPadding(table, 1, 2);
291-
292-
assert.equal(pad, " ");
293-
});
294-
295-
test("getRightPadding() Last column is empty string gets right padded with maxColLength characters if there is right border", () => {
296-
const sut = createCalculator();
297-
const table = tableFor([
298-
[ "aaaaa", "bbbbb", "ccccc" ],
299-
[ "aaaaa", "bbbbb", "" ]
300-
]);
301-
table.hasRightBorder = true;
302-
303-
const pad = sut.getRightPadding(table, 1, 2);
304-
305-
assert.equal(pad, " ");
306-
});
307-
308-
test("getRightPadding() Last column with 0 maxLength gets right padded with 1 characters if there is right border", () => {
309-
const sut = createCalculator();
310-
const table = tableFor([
311-
[ "aaaaa", "bbbbb", "" ],
312-
[ "aaaaa", "bbbbb", "" ]
313-
]);
314-
table.hasRightBorder = true;
315-
316-
const pad = sut.getRightPadding(table, 1, 2);
317-
318-
assert.equal(pad, " ");
319-
});
320-
321-
test("Regular middle gets padded both left and right with expected amount", () => {
322-
const sut = createCalculator();
323-
const table = tableFor([
324-
[ "aaaaa", "bbbbb", "ccccc" ],
325-
[ "aaaaa", "b", "ccccc" ]
326-
]);
327-
328-
const leftPad = sut.getLeftPadding(table, 1, 1);
329-
const rightPad = sut.getRightPadding(table, 1, 1);
330-
331-
assert.equal(leftPad, " ");
332-
assert.equal(rightPad, " ");
333-
});
334-
33512
function tableFor(rows: string[][]) {
33613
const alignments: Alignment[] = rows[0].map(r => Alignment.Left);
33714
let table = new Table(rows.map(row => row.map(c => new Cell(c))), alignments);

0 commit comments

Comments
 (0)