generated from skedwards88/template-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f72bcb3
commit 5c49cb6
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {centerIndexes} from "./centerIndexes"; | ||
|
||
test("Given indexes in a grid, returns the indexes of the centered input indexes", () => { | ||
const indexes = [11,15,17,20,21] | ||
|
||
const centeredIndexes = centerIndexes(indexes, 5); | ||
|
||
const expectedIndexes = [7,11,13,16,17] | ||
|
||
expect(centeredIndexes).toEqual(expectedIndexes); | ||
}); | ||
|
||
|
||
test("If the indexes can't be perfectly centered, errs towards the top left", () => { | ||
const expectedIndexes = [8,13,14,15,20] | ||
|
||
const indexesBottomLeft = [19,24,25,26,31] | ||
|
||
expect(centerIndexes(indexesBottomLeft, 6)).toEqual(expectedIndexes); | ||
|
||
const indexesBottomRight = [22,27,28,29,34] | ||
|
||
expect(centerIndexes(indexesBottomRight, 6)).toEqual(expectedIndexes); | ||
|
||
const indexesTopLeft = [1,6,7,8,13] | ||
|
||
expect(centerIndexes(indexesTopLeft, 6)).toEqual(expectedIndexes); | ||
|
||
const indexesTopRight = [4,9,10,11,16] | ||
|
||
expect(centerIndexes(indexesTopRight, 6)).toEqual(expectedIndexes); | ||
}); | ||
|
||
test("If the indexes are already centered up/down, will still center right/left", () => { | ||
const indexes = [6,10,12,15,16] | ||
|
||
const centeredIndexes = centerIndexes(indexes, 5); | ||
|
||
const expectedIndexes = [7,11,13,16,17] | ||
|
||
expect(centeredIndexes).toEqual(expectedIndexes); | ||
}); | ||
|
||
test("If the indexes are already centered right/left, will still center up/down", () => { | ||
const indexes = [12,16,18,21,22] | ||
|
||
const centeredIndexes = centerIndexes(indexes, 5); | ||
|
||
const expectedIndexes = [7,11,13,16,17] | ||
|
||
expect(centeredIndexes).toEqual(expectedIndexes); | ||
}); |