Skip to content

Commit

Permalink
Dia 05: refatorando constantes dos testes
Browse files Browse the repository at this point in the history
  • Loading branch information
laisfrigerio committed Feb 16, 2023
1 parent a4c1def commit 7eda224
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 38 deletions.
40 changes: 40 additions & 0 deletions tests/aux/consts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

const NOTIFICATION_DISPLAY_LETTER_SUCCESSFULLY = 'Showing letter with success'
const NOTIFICATION_BACKSPACE_KEY_PRESSED = 'Backspace key pressed'
const NOTIFICATION_BACKSPACE_WHEN_EMPTY_GUESS = 'Could not erase when is an empty guess'
const NOTIFICATION_EMPTY_GUESS = 'Empty guess'
const NOTIFICATION_ENTER_KEY_PRESSED = 'Enter key pressed'
const NOTIFICATION_INCOMPLETE_GUESS = 'Incomplete guess'
const NOTIFICATION_INVALID_PRESSED_KEY = 'Invalid Pressed Key'
const NOTIFICATION_REACH_MAX_ATTEMPTS = 'Reach Max Attempts'
const NOTIFICATION_REACH_MAX_LETTERS_PER_ROW = 'Reach Max letter per row'
const NOTIFICATION_WORD_NOT_IN_DATABASE = 'Word not in database'
const NOTIFICATION_GAME_OVER_GUESS_RIGHT = 'You guessed right! Game over!'

const GREEN_COLOR_RGB = 'rgb(83, 141, 78)'
const GRAY_COLOR_RGB = 'rgb(88, 88, 88)'
const YELLOW_COLOR_RGB = 'rgb(181, 159, 59)'

const KEY_BACKSPACE = 'Backspace'
const KEY_ENTER = 'Enter'
const KEY_DELETE = 'Delete'

module.exports = {
NOTIFICATION_DISPLAY_LETTER_SUCCESSFULLY,
NOTIFICATION_BACKSPACE_KEY_PRESSED,
NOTIFICATION_BACKSPACE_WHEN_EMPTY_GUESS,
NOTIFICATION_EMPTY_GUESS,
NOTIFICATION_ENTER_KEY_PRESSED,
NOTIFICATION_INCOMPLETE_GUESS,
NOTIFICATION_INVALID_PRESSED_KEY,
NOTIFICATION_REACH_MAX_ATTEMPTS,
NOTIFICATION_REACH_MAX_LETTERS_PER_ROW,
NOTIFICATION_WORD_NOT_IN_DATABASE,
NOTIFICATION_GAME_OVER_GUESS_RIGHT,
GREEN_COLOR_RGB,
GRAY_COLOR_RGB,
YELLOW_COLOR_RGB,
KEY_BACKSPACE,
KEY_ENTER,
KEY_DELETE,
}
7 changes: 7 additions & 0 deletions tests/aux/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const getGameBoardLetter = (index) => {
return global.document.querySelector(`.letter-${index}`).style.backgroundColor
}

module.exports = {
getGameBoardLetter
}
21 changes: 10 additions & 11 deletions tests/check-guess.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ const { JSDOM } = require('jsdom')
const path = require('path')
const app = require('../resources/scripts/app')

const NOTIFICATION_EMPTY_GUESS = 'Empty guess'
const NOTIFICATION_ENTER_KEY_PRESSED = 'Enter key pressed'
const NOTIFICATION_INCOMPLETE_GUESS = 'Incomplete guess'
const NOTIFICATION_WORD_NOT_IN_DATABASE = 'Word not in database'
const NOTIFICATION_GAME_OVER_GUESS_RIGHT = 'You guessed right! Game over!'

const GREEN_COLOR_RGB = 'rgb(83, 141, 78)'

const getGameBoardLetter = (index) => {
return global.document.querySelector(`.letter-${index}`).style.backgroundColor
}
const {
NOTIFICATION_EMPTY_GUESS,
NOTIFICATION_ENTER_KEY_PRESSED,
NOTIFICATION_GAME_OVER_GUESS_RIGHT,
NOTIFICATION_INCOMPLETE_GUESS,
NOTIFICATION_WORD_NOT_IN_DATABASE,
GREEN_COLOR_RGB
} = require('./aux/consts')

const { getGameBoardLetter } = require('./aux/helpers')

describe('Checking guess', () => {
const database = ['agent', 'above', 'lunch', 'money', 'sorry', 'today', 'worry']
Expand Down
12 changes: 6 additions & 6 deletions tests/display-color.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ const { JSDOM } = require('jsdom')
const path = require('path')
const app = require('../resources/scripts/app')

const GREEN_COLOR_RGB = 'rgb(83, 141, 78)'
const GRAY_COLOR_RGB = 'rgb(88, 88, 88)'
const YELLOW_COLOR_RGB = 'rgb(181, 159, 59)'
const {
GREEN_COLOR_RGB,
YELLOW_COLOR_RGB,
GRAY_COLOR_RGB
} = require('./aux/consts')

const getGameBoardLetter = (index) => {
return global.document.querySelector(`.letter-${index}`).style.backgroundColor
}
const { getGameBoardLetter } = require('./aux/helpers')

describe('Testing display color...', () => {
const database = ['agent', 'above', 'allow', 'lunch', 'money', 'sorry', 'today', 'worry']
Expand Down
40 changes: 19 additions & 21 deletions tests/on-key-pressed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ const { JSDOM } = require('jsdom')
const path = require('path')
const app = require('../resources/scripts/app')

const NOTIFICATION_DISPLAY_LETTER_SUCCESSFULLY = 'Showing letter with success'
const NOTIFICATION_BACKSPACE_KEY_PRESSED = 'Backspace key pressed'
const NOTIFICATION_BACKSPACE_WHEN_EMPTY_GUESS = 'Could not erase when is an empty guess'
const NOTIFICATION_EMPTY_GUESS = 'Empty guess'
const NOTIFICATION_ENTER_KEY_PRESSED = 'Enter key pressed'
const NOTIFICATION_INCOMPLETE_GUESS = 'Incomplete guess'
const NOTIFICATION_INVALID_PRESSED_KEY = 'Invalid Pressed Key'
const NOTIFICATION_REACH_MAX_ATTEMPTS = 'Reach Max Attempts'
const NOTIFICATION_REACH_MAX_LETTERS_PER_ROW = 'Reach Max letter per row'
const NOTIFICATION_WORD_NOT_IN_DATABASE = 'Word not in database'
const NOTIFICATION_GAME_OVER_GUESS_RIGHT = 'You guessed right! Game over!'

const KEY_BACKSPACE = 'Backspace'
const KEY_ENTER = 'Enter'
const KEY_DELETE = 'Delete'

const GREEN_COLOR_RGB = 'rgb(83, 141, 78)'

const getGameBoardLetter = (index) => {
return global.document.querySelector(`.letter-${index}`).style.backgroundColor
}
const {
NOTIFICATION_DISPLAY_LETTER_SUCCESSFULLY,
NOTIFICATION_BACKSPACE_KEY_PRESSED,
NOTIFICATION_BACKSPACE_WHEN_EMPTY_GUESS,
NOTIFICATION_EMPTY_GUESS,
NOTIFICATION_ENTER_KEY_PRESSED,
NOTIFICATION_INCOMPLETE_GUESS,
NOTIFICATION_INVALID_PRESSED_KEY,
NOTIFICATION_REACH_MAX_ATTEMPTS,
NOTIFICATION_REACH_MAX_LETTERS_PER_ROW,
NOTIFICATION_WORD_NOT_IN_DATABASE,
NOTIFICATION_GAME_OVER_GUESS_RIGHT,
GREEN_COLOR_RGB,
KEY_BACKSPACE,
KEY_ENTER,
KEY_DELETE,
} = require('./aux/consts')

const { getGameBoardLetter } = require('./aux/helpers')

describe('Testing on key pressed', () => {
const database = ['agent', 'above', 'allow', 'lunch', 'money', 'sorry', 'today', 'worry']
Expand Down

0 comments on commit 7eda224

Please sign in to comment.