Skip to content

Commit

Permalink
fix: resolved formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Feb 10, 2021
1 parent 6f323fe commit eafe47c
Showing 1 changed file with 55 additions and 286 deletions.
341 changes: 55 additions & 286 deletions tests/connectFour.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,307 +13,76 @@ describe('ConnectFour', () => {

test('GIVEN array THEN throws TypeError', () => {
// @ts-expect-error
expect(() =>
connectFour([
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
])
).toThrow('data must be a typed array');
// prettier-ignore
expect(() => connectFour([
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
])).toThrow('data must be a typed array');
});

test('GIVEN Uint8Array with too little elements THEN throws TypeError', () => {
expect(() =>
connectFour(
new Uint8Array([
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
])
)
).toThrow('data must have exactly 42 numbers');
// prettier-ignore
expect(() => connectFour(new Uint8Array([
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0
]))).toThrow('data must have exactly 42 numbers');
});

test('GIVEN Uint8Array with too many elements THEN throws TypeError', () => {
expect(() =>
connectFour(
new Uint8Array([
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
])
)
).toThrow('data must have exactly 42 numbers');
// prettier-ignore
expect(() => connectFour(new Uint8Array([
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0
]))).toThrow('data must have exactly 42 numbers');
});

test('GIVEN empty board THEN returns 4', () => {
expect(
connectFour(
new Uint8Array([
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
])
)
).toEqual(3);
// prettier-ignore
expect(connectFour(new Uint8Array([
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
]))).toEqual(3);
});

test('GIVEN possible horizontal row (0..2) THEN returns 3', () => {
expect(
connectFour(
new Uint8Array([
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
2,
2,
2,
0,
0,
0,
0
])
)
).toEqual(3);
// prettier-ignore
expect(connectFour(new Uint8Array([
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0,
2, 2, 2, 0, 0, 0, 0
]))).toEqual(3);
});

test('GIVEN possible horizontal row (1..3) THEN returns 4', () => {
expect(
connectFour(
new Uint8Array([
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
1,
2,
2,
2,
0,
0,
0
])
)
).toEqual(4);
// prettier-ignore
expect(connectFour(new Uint8Array([
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0,
1, 2, 2, 2, 0, 0, 0
]))).toEqual(4);
});

test.skip('GIVEN possible vertical row (0) THEN returns 4', () => {
Expand Down

0 comments on commit eafe47c

Please sign in to comment.