Created
October 13, 2019 11:09
-
-
Save CristianoRC/3b830a3191a9acfe5633c2a47c722ffb to your computer and use it in GitHub Desktop.
Exemplos do Jest
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
describe('Função de soma', () => { | |
it('Deve somar o numero passado por parâmetro com 1', () => { | |
expect((adicionarUm(10))).toBe(11) | |
}) | |
}) | |
test('O Array deve ser preenchido da maneira correta', () => { | |
const numeros = { um: 1 }; | |
numeros['dois'] = 2; | |
numeros['tres'] = 3 | |
expect(numeros).toEqual({ um: 1, dois: 2, tres: 3 }); | |
}); | |
test('Deve validar se Zero é um numero', () => { | |
const zero = 0; | |
expect(zero).not.toBeNull(); | |
expect(zero).toBeDefined(); | |
expect(zero).not.toBeUndefined(); | |
expect(zero).not.toBeTruthy(); | |
expect(zero).toBeFalsy(); | |
expect(typeof zero).toBe('number'); | |
}); | |
test('A soma nunca deve ser igual a Zero', () => { | |
for (let a = 1; a < 10; a++) { | |
for (let b = 1; b < 10; b++) { | |
expect(a + b).not.toBe(0); | |
} | |
} | |
}); | |
const adicionarUm = (valor) => valor + 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment