Crea tres test sobre el reto 12: "Viernes 13".
- Puedes copiar una solución ya creada por otro usuario en el lenguaje que estés utilizando.
- Debes emplear un mecanismo de ejecución de test que posea el lenguaje de programación que hayas seleccionado.
- Los tres test deben de funcionar y comprobar diferentes situaciones (a tu elección).
const includesFriday13 = require('../12-viernes-13/solution');
describe('Challenge 12: Viernes 13', () => {
const testCases = [
{
input: [2, 2016],
output: false,
},
{
input: [4, 1990],
output: true,
},
{
input: [7, 1990],
output: true,
},
{
input: [11, 2009],
output: true,
},
{
input: [8, 2010],
output: true,
},
{
input: [5, 2011],
output: true,
},
{
input: [1, 1985],
output: false,
},
{
input: [8, 2021],
output: true,
},
{
input: [1, 2023],
output: true,
},
{
input: [10, 2023],
output: true,
},
];
it('should return a boolean type', () => {
expect(typeof includesFriday13(1, 2023)).toBe('boolean');
});
it.each(testCases)('should return $output', (testCase) => {
expect(includesFriday13(...testCase.input)).toBe(testCase.output);
});
});- First, I use the
describefunction to group the tests.
describe('Challenge 12: Viernes 13', () => {
// ...
});- Then, I create a variable called
testCasesthat contains the test cases.
const testCases = [
{
input: [2, 2016],
output: false,
},
{
input: [4, 1990],
output: true,
},
{
input: [7, 1990],
output: true,
},
{
input: [11, 2009],
output: true,
},
{
input: [8, 2010],
output: true,
},
{
input: [5, 2011],
output: true,
},
{
input: [1, 1985],
output: false,
},
{
input: [8, 2021],
output: true,
},
{
input: [1, 2023],
output: true,
},
{
input: [10, 2023],
output: true,
},
];- Then, I use the
itfunction to create the tests.
it('should return a boolean type', () => {
expect(typeof includesFriday13(1, 2023)).toBe('boolean');
});
it.each(testCases)('should return $output', (testCase) => {
expect(includesFriday13(...testCase.input)).toBe(testCase.output);
});- Finally, I use the
expectfunction to check the output of the function.
expect(typeof includesFriday13(1, 2023)).toBe('boolean');
expect(includesFriday13(...testCase.input)).toBe(testCase.output);