From 1c552c48f428b859ffb450dbbae009026b9de2ad Mon Sep 17 00:00:00 2001 From: Abbe Keultjes Date: Tue, 30 Mar 2021 21:18:05 +0200 Subject: [PATCH] feat(hex): toString() now also accepts cube coordinates --- src/hex/functions/toString.test.ts | 1 + src/hex/functions/toString.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hex/functions/toString.test.ts b/src/hex/functions/toString.test.ts index e9d2667c..6dc2dff3 100644 --- a/src/hex/functions/toString.test.ts +++ b/src/hex/functions/toString.test.ts @@ -2,4 +2,5 @@ import { toString } from './toString' test('returns a string representation of the hex coordinates', () => { expect(toString({ q: 1, r: 2 })).toBe('1,2') + expect(toString({ q: 1, r: 2, s: -3 })).toBe('1,2') }) diff --git a/src/hex/functions/toString.ts b/src/hex/functions/toString.ts index 99d53b9c..5b2eed39 100644 --- a/src/hex/functions/toString.ts +++ b/src/hex/functions/toString.ts @@ -1,3 +1,3 @@ -import { AxialCoordinates } from '../types' +import { PartialCubeCoordinates } from '../types' -export const toString = ({ q, r }: AxialCoordinates) => `${q},${r}` +export const toString = ({ q, r }: PartialCubeCoordinates) => `${q},${r}`