-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(grid): rename at() to add() and make it accept multiple coor…
…dinates The word "at" will have a different meaning, that's why it's renamed. BREAKING CHANGE: The at() traverser is renamed to add()
- Loading branch information
1 parent
256879f
commit e63f650
Showing
11 changed files
with
41 additions
and
41 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
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { createHex, createHexPrototype } from '../../hex' | ||
import { Grid } from '../grid' | ||
import { at } from '../traversers' | ||
import { add } from '../traversers' | ||
import { inStore } from './inStore' | ||
|
||
test('returns whether the passed hex is present in the passed store', () => { | ||
const hexPrototype = createHexPrototype() | ||
const hex = createHex(hexPrototype, { q: 1, r: 2 }) | ||
|
||
expect(inStore(hex, new Grid(hexPrototype, new Map([[hex.toString(), hex]])))).toBe(true) | ||
expect(inStore(hex, new Grid(hexPrototype, at({ q: 3, r: 4 })))).toBe(false) | ||
expect(inStore(hex, new Grid(hexPrototype, add({ q: 3, r: 4 })))).toBe(false) | ||
expect(inStore(hex, new Grid(hexPrototype))).toBe(false) | ||
}) |
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,13 @@ | ||
import { Hex } from '../../hex' | ||
import { add } from './add' | ||
|
||
test('accepts coordinates and returns a traverser that returns the hex with those coordinates', () => { | ||
const getHex = jest.fn((coordinates) => coordinates) | ||
|
||
expect(add({ q: 1, r: 2 }, { q: 3, r: 4 })({} as Hex, getHex)).toEqual([ | ||
{ q: 1, r: 2 }, | ||
{ q: 3, r: 4 }, | ||
]) | ||
expect(getHex).toBeCalledWith({ q: 1, r: 2 }) | ||
expect(getHex).toBeCalledWith({ q: 3, r: 4 }) | ||
}) |
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,5 @@ | ||
import { Hex, HexCoordinates } from '../../hex' | ||
import { Traverser } from '../types' | ||
|
||
export const add = <T extends Hex>(...coordinates: HexCoordinates[]): Traverser<T> => (_, getHex) => | ||
coordinates.map((coords) => getHex(coords)) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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