Skip to content

Commit

Permalink
js_2048_game: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ihor Oliinyk committed Nov 20, 2020
1 parent 4636ec0 commit 096b769
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
58 changes: 58 additions & 0 deletions cypress/integration/js2048Game.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

describe('2048 game', () => {
beforeEach('Open site', () => {
cy.visit('https://kshvetsova.github.io/js_2048_game/');
});

it('should show the score', () => {
cy.get('button').click();
cy.get('body').type('{rightArrow}');
cy.get('body').type('{upArrow}');
cy.get('body').type('{rightArrow}');
cy.contains('Score').should('not.have.value', 0);
});

it('should show the score', () => {
cy.get('button').click();
cy.get('body').type('{leftArrow}');
cy.get('body').type('{upArrow}');
cy.get('body').type('{leftArrow}');
cy.contains('Score').should('not.have.value', 0);
});

it('should show the score', () => {
cy.get('button').click();
cy.get('body').type('{rightArrow}');
cy.get('body').type('{downArrow}');
cy.get('body').type('{rightArrow}');
cy.contains('Score').should('not.have.value', 0);
});

it('should show the score', () => {
cy.get('button').click();
cy.get('body').type('{leftArrow}');
cy.get('body').type('{downArrow}');
cy.get('body').type('{leftArrow}');
cy.contains('Score').should('not.have.value', 0);
});

it('should reset the score', () => {
cy.get('button').click();
cy.get('body').type('{leftArrow}');
cy.get('body').type('{downArrow}');
cy.get('body').type('{leftArrow}');
cy.get('[class="game-score"]').should('not.have.value', '0');
cy.get('button').click();
cy.get('[class="game-score"]').should('have.value', '');
});

it('should show message wh', () => {
cy.get('button').click();
for (let n = 0; n < 120; n++) {
cy.get('body').type('{rightArrow}');
cy.get('body').type('{upArrow}');
}
cy.get('body').contains('lose');
});
});
8 changes: 0 additions & 8 deletions cypress/integration/page.spec.js

This file was deleted.

0 comments on commit 096b769

Please sign in to comment.