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
it('should toggle flag of a block', () => { | |
cy.visit("/"); | |
cy.get(".flag").should("not.be.visible"); | |
const block = cy.get(".block").first(); | |
block.rightclick(); | |
cy.get(".flag").should("be.visible"); | |
block.rightclick(); | |
cy.get(".flag").should("not.be.visible"); | |
}) |
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
it('should reveal block', () => { | |
const rows = 5; | |
const columns = 5; | |
const board = new Board(rows, columns); | |
const { container } = render(<BoardComponent board={board} />) | |
const block = container.querySelectorAll('.block')[0]; | |
fireEvent.click(block); | |
expect(board.blocks[0][0].revealed).toBe(true); | |
}) |
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
it('should call onRevealed after left click', () => { | |
const block = new Block(position); | |
const reveal = jest.fn(); | |
const { getByTestId } = render(<BlockComponent block={block} onReveal={reveal} />); | |
const root = getByTestId(`block-${position.row}-${position.column}`); | |
fireEvent.click(root); | |
expect(reveal).toHaveBeenCalled(); | |
}) |
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
it('should explode if it has mine', () => { | |
const mine = true; | |
const block = new Block(new Position(1, 1), mine); | |
const { mineExploded } = block.reveal([]); | |
expect(mineExploded).toBeTruthy(); | |
}) | |
it('should not explode if it does not have mine', () => { | |
const block = new Block(new Position(1, 1)); | |
const { mineExploded } = block.reveal([]); |