Skip to content

Commit 6e7eedb

Browse files
committed
Increase coverage testing
1 parent 883298f commit 6e7eedb

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

src/selection.test.ts

+34-7
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,41 @@ describe("new EntireColumnsSelection()", () => {
6161
});
6262
});
6363

64-
describe("new EntireTableSelection()", () => {
64+
describe("EntireTableSelection", () => {
6565
test("creates entire table selection", () => {
6666
new EntireTableSelection();
6767
});
68+
test("toRange() returns the range of entire table", () => {
69+
const selection = new EntireTableSelection();
70+
expect(selection.toRange(EXAMPLE_DATA)).toEqual(
71+
getMatrixRange(EXAMPLE_DATA)
72+
);
73+
});
74+
test("normalizeTo() returns the same object", () => {
75+
const selection = new EntireTableSelection();
76+
expect(selection.normalizeTo(EXAMPLE_DATA)).toEqual(selection);
77+
});
78+
test("hasEntireRow() returns true for any row", () => {
79+
const selection = new EntireTableSelection();
80+
expect(selection.hasEntireRow(0)).toBe(true);
81+
expect(selection.hasEntireRow(1)).toBe(true);
82+
});
83+
test("hasEntireColumn() returns true for any column", () => {
84+
const selection = new EntireTableSelection();
85+
expect(selection.hasEntireColumn(0)).toBe(true);
86+
expect(selection.hasEntireColumn(1)).toBe(true);
87+
});
88+
test("size() returns the size of entire table", () => {
89+
const selection = new EntireTableSelection();
90+
expect(selection.size(EXAMPLE_DATA)).toBe(
91+
EXAMPLE_DATA_ROWS_COUNT * EXAMPLE_DATA_COLUMNS_COUNT
92+
);
93+
});
94+
test("has() returns true for any point", () => {
95+
const selection = new EntireTableSelection();
96+
expect(selection.has(EXAMPLE_DATA, Point.ORIGIN)).toBe(true);
97+
expect(selection.has(EXAMPLE_DATA, EXAMPLE_DATA_MAX_POINT)).toBe(true);
98+
});
6899
});
69100

70101
describe("Selection.prototype.toRange()", () => {
@@ -263,12 +294,8 @@ describe("Selection.prototype.hasEntireColumn()", () => {
263294
1,
264295
false,
265296
],
266-
[
267-
"returns false for non-entire-columns selection",
268-
new EmptySelection(),
269-
0,
270-
false,
271-
],
297+
["returns false for empty selection", new EmptySelection(), 0, false],
298+
["returns false for empty selection", new EmptySelection(), 0, false],
272299
];
273300
test.each(cases)("%s", (name, selection, column, expected) => {
274301
expect(selection.hasEntireColumn(column)).toBe(expected);

src/selection.ts

-12
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ export abstract class EntireAxisSelection extends EntireSelection {
134134
this.start = Math.min(start, end);
135135
this.end = Math.max(start, end);
136136
}
137-
138-
/** Immutably set given property with given value */
139-
set(property: "start" | "end", value: number): this {
140-
if (!isIndex(value)) {
141-
throw new InvalidIndexError(property);
142-
}
143-
const { start, end } = this;
144-
const data = { start, end };
145-
data[property] = value;
146-
// @ts-expect-error
147-
return new this.constructor(data.start, data.end);
148-
}
149137
}
150138

151139
/** Selection of entire rows in the spreadsheet */

0 commit comments

Comments
 (0)