-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.test.js
38 lines (30 loc) · 1.1 KB
/
functions.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { sayHello, olaMundo, removeSpacing, countingStrings, remAndUpper, consultApi } = require('./functions')
const stringTest = ' String com espaços '
test('Deve printar Hello World', () => {
expect(sayHello()).toBe('Hello World!')
})
test('Deve printar Olá Mundo!', () => {
expect(olaMundo()).toBe('Olá Mundo!')
})
test('Deve retornar string sem espaços', () => {
expect(removeSpacing(stringTest)).toBe('String com espaços')
})
test('Deve contar quantos caracteres tem na string', () => {
const countedString = 'Cadeiras'
expect(countingStrings(countedString)).toBe(8)
})
test('Deve remover espaços e colocar em uppercase', () => {
let finalString = remAndUpper(stringTest)
expect(finalString).toBe('STRING COM ESPAÇOS')
})
test('Deve consultar uma api', async () => {
const url = 'https://jsonplaceholder.typicode.com/todos/1'
const result = await consultApi(url)
expect(typeof result).toBe('object')
console.log(result)
})
test('Deve retornar um erro, por url inválida', async() => {
const url = ''
const result = await consultApi(url)
expect(result.name).toBe('TypeError')
})