Probar String
const text = "Hola Mundo";
test('Debe contener Mundo', ()=>{
expect(text).toMach(/Mundo/);
})
Probar Array
test('¿Tenemos mango?', ()=>{
expect(fruits).toContain('mango')
})
Probar números
test('Mayor que', ()=>{
expect(10).toBeGreaterThan(9)
})
Probar booleano
test('Verdadero', ()=>{
expect(true).toBeTruthy()
})
Probar callback
const reverseString = (str, callback) => {
callback(str.slipt("").reverse().join(""))
}
test('Probar un callback', ()=>{
reverseString('hola', (str)=>{
expect(str).toBe('aloh')
})
})
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?