This file contains hidden or 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
| button.cell + button.cell { | |
| margin: 0; | |
| } | |
| .board { | |
| /* border: 1px solid black; */ | |
| display: grid; | |
| grid-template-columns: repeat(3, 1fr); | |
| grid-gap: 0px; | |
| width: 300px; |
This file contains hidden or 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
| import * as R from 'ramda' | |
| export default class TicTacToe { | |
| constructor(fields, currentPlayer = 'X') { | |
| this.fields = fields; | |
| this.currentPlayer = currentPlayer; | |
| }; | |
| static startWithSize(width, height) { | |
| return new TicTacToe(Array(width * height).fill(" ")); |
This file contains hidden or 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
| import React from 'react' | |
| export const Cell = ({ owner = '', cellNr, onClick } = { owner: '' }) => | |
| <button | |
| className={`cell cell_${cellNr}`} | |
| data-cell-nr={cellNr} | |
| onClick={onClick} | |
| data-testid="cell"> | |
| {owner} | |
| </button>; |
This file contains hidden or 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
| import React, {useState} from 'react' | |
| import {Cell} from "./cell.js" | |
| import * as R from 'ramda' | |
| const mapIndexed = R.addIndex(R.map); | |
| export const Board = props => { | |
| const [state, setState] = useState(props.game); | |
| const handleCellClick = e => setState(state.mark(Number(e.target.dataset["cellNr"]))); |
This file contains hidden or 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
| ● greater than in obj › jest equal | |
| expect(received).toBeTruthy() | |
| Received: false | |
| ● greater than in obj › jest greater | |
| expect(received).toBeGreaterThan(expected) |
This file contains hidden or 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
| ● greater than in obj › jest equal | |
| expect(received).toBeTruthy() | |
| Received: false | |
| ● greater than in obj › jest greater | |
| expect(received).toBeGreaterThan(expected) |
This file contains hidden or 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
| describe("...", () => { | |
| it("...", () => { | |
| ... | |
| }) | |
| }); |
This file contains hidden or 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
| it('should have the right number of cells', () => { | |
| const { container, getAllByTestId } = render(<Board game={TicTacToe.startWithSize(4, 4)} />); | |
| expect( | |
| getAllByTestId("cell").length | |
| ).toEqual(16); | |
| }); |
This file contains hidden or 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
| describe('Board', () => { | |
| it('should have the right number of cells', () => { | |
| const wrapper = shallow(<Board game={TicTacToe.startWithSize(4, 4)} />); | |
| expect(wrapper.find(Cell).length).toEqual(16); | |
| }); | |
| }); |
This file contains hidden or 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
| describe('GET /user', function() { | |
| it('responds with json', function(done) { | |
| request(app) | |
| .get('/user') | |
| .set('Accept', 'application/json') | |
| .expect('Content-Type', /json/) | |
| .expect(200, done); | |
| }); | |
| }); |
NewerOlder