From 6cdfce51b168e4bdc09b82f6e2b73fd2139b8790 Mon Sep 17 00:00:00 2001 From: Luiz Date: Wed, 6 Mar 2024 15:28:00 -0300 Subject: [PATCH] teste do array-operation no js --- .../js/code/array-operations.jest.test.js | 48 +++++++++++++++++++ .../_codes/js/code/array-operations.test.js | 29 +++++++---- .../_codes/js/code/package.json | 3 ++ .../js/response/array-operations.jest.test.js | 48 +++++++++++++++++++ .../js/response/array-operations.test.js | 29 +++++++---- .../_codes/js/response/package.json | 3 ++ 6 files changed, 142 insertions(+), 18 deletions(-) create mode 100644 src/pages/exercises/array-operations/_codes/js/code/array-operations.jest.test.js create mode 100644 src/pages/exercises/array-operations/_codes/js/code/package.json create mode 100644 src/pages/exercises/array-operations/_codes/js/response/array-operations.jest.test.js create mode 100644 src/pages/exercises/array-operations/_codes/js/response/package.json diff --git a/src/pages/exercises/array-operations/_codes/js/code/array-operations.jest.test.js b/src/pages/exercises/array-operations/_codes/js/code/array-operations.jest.test.js new file mode 100644 index 00000000..4601b2f0 --- /dev/null +++ b/src/pages/exercises/array-operations/_codes/js/code/array-operations.jest.test.js @@ -0,0 +1,48 @@ +import { sum, product, sumOdds } from './array-operations.js'; + +describe('Array Operation', () => { + test('adding values from [1, 2, 3]', () => { + let values = [1, 2, 3]; + expect(sum(values)).toBe(6); + }); + + test.skip('adding values from [2, 2, 2]', () => { + let values = [2, 2, 2]; + expect(sum(values)).toBe(6); + }); + + test.skip('adding values from [1, 2, 3, 4, 5, 6]', () => { + let values = [1, 2, 3, 4, 5, 6]; + expect(sum(values)).toBe(21); + }); + + test.skip('adding odd values from [1, 2, 3]', () => { + let values = [1, 2, 3]; + expect(sumOdds(values)).toBe(4); + }); + + test.skip('adding odd values from [2, 2, 2]', () => { + let values = [2, 2, 2]; + expect(sumOdds(values)).toBe(0); + }); + + test.skip('adding odd values from [1, 2, 3, 4, 5, 6]', () => { + let values = [1, 2, 3, 4, 5, 6]; + expect(sumOdds(values)).toBe(9); + }); + + test.skip('multiplying values from [1, 2, 3]', () => { + let values = [1, 2, 3]; + expect(product(values)).toBe(6); + }); + + test.skip('multiplying values from [2, 2, 2]', () => { + let values = [2, 2, 2]; + expect(product(values)).toBe(8); + }); + + test.skip('multiplying values from [1, 2, 3, 4, 5, 6]', () => { + let values = [1, 2, 3, 4, 5, 6]; + expect(product(values)).toBe(720); + }); +}); diff --git a/src/pages/exercises/array-operations/_codes/js/code/array-operations.test.js b/src/pages/exercises/array-operations/_codes/js/code/array-operations.test.js index 4601b2f0..1268c6a3 100644 --- a/src/pages/exercises/array-operations/_codes/js/code/array-operations.test.js +++ b/src/pages/exercises/array-operations/_codes/js/code/array-operations.test.js @@ -1,48 +1,59 @@ +import { describe, test } from 'node:test'; +import assert from 'node:assert'; import { sum, product, sumOdds } from './array-operations.js'; describe('Array Operation', () => { test('adding values from [1, 2, 3]', () => { let values = [1, 2, 3]; - expect(sum(values)).toBe(6); + + assert.equal(sum(values), 6); }); test.skip('adding values from [2, 2, 2]', () => { let values = [2, 2, 2]; - expect(sum(values)).toBe(6); + + assert.equal(sum(values), 6); }); test.skip('adding values from [1, 2, 3, 4, 5, 6]', () => { let values = [1, 2, 3, 4, 5, 6]; - expect(sum(values)).toBe(21); + + assert.equal(sum(values), 21); }); test.skip('adding odd values from [1, 2, 3]', () => { let values = [1, 2, 3]; - expect(sumOdds(values)).toBe(4); + + assert.equal(sumOdds(values), 4); }); test.skip('adding odd values from [2, 2, 2]', () => { let values = [2, 2, 2]; - expect(sumOdds(values)).toBe(0); + + assert.equal(sumOdds(values), 0); }); test.skip('adding odd values from [1, 2, 3, 4, 5, 6]', () => { let values = [1, 2, 3, 4, 5, 6]; - expect(sumOdds(values)).toBe(9); + + assert.equal(sumOdds(values), 9); }); test.skip('multiplying values from [1, 2, 3]', () => { let values = [1, 2, 3]; - expect(product(values)).toBe(6); + + assert.equal(product(values), 6); }); test.skip('multiplying values from [2, 2, 2]', () => { let values = [2, 2, 2]; - expect(product(values)).toBe(8); + + assert.equal(product(values), 8); }); test.skip('multiplying values from [1, 2, 3, 4, 5, 6]', () => { let values = [1, 2, 3, 4, 5, 6]; - expect(product(values)).toBe(720); + + assert.equal(product(values), 720); }); }); diff --git a/src/pages/exercises/array-operations/_codes/js/code/package.json b/src/pages/exercises/array-operations/_codes/js/code/package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/src/pages/exercises/array-operations/_codes/js/code/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/src/pages/exercises/array-operations/_codes/js/response/array-operations.jest.test.js b/src/pages/exercises/array-operations/_codes/js/response/array-operations.jest.test.js new file mode 100644 index 00000000..4601b2f0 --- /dev/null +++ b/src/pages/exercises/array-operations/_codes/js/response/array-operations.jest.test.js @@ -0,0 +1,48 @@ +import { sum, product, sumOdds } from './array-operations.js'; + +describe('Array Operation', () => { + test('adding values from [1, 2, 3]', () => { + let values = [1, 2, 3]; + expect(sum(values)).toBe(6); + }); + + test.skip('adding values from [2, 2, 2]', () => { + let values = [2, 2, 2]; + expect(sum(values)).toBe(6); + }); + + test.skip('adding values from [1, 2, 3, 4, 5, 6]', () => { + let values = [1, 2, 3, 4, 5, 6]; + expect(sum(values)).toBe(21); + }); + + test.skip('adding odd values from [1, 2, 3]', () => { + let values = [1, 2, 3]; + expect(sumOdds(values)).toBe(4); + }); + + test.skip('adding odd values from [2, 2, 2]', () => { + let values = [2, 2, 2]; + expect(sumOdds(values)).toBe(0); + }); + + test.skip('adding odd values from [1, 2, 3, 4, 5, 6]', () => { + let values = [1, 2, 3, 4, 5, 6]; + expect(sumOdds(values)).toBe(9); + }); + + test.skip('multiplying values from [1, 2, 3]', () => { + let values = [1, 2, 3]; + expect(product(values)).toBe(6); + }); + + test.skip('multiplying values from [2, 2, 2]', () => { + let values = [2, 2, 2]; + expect(product(values)).toBe(8); + }); + + test.skip('multiplying values from [1, 2, 3, 4, 5, 6]', () => { + let values = [1, 2, 3, 4, 5, 6]; + expect(product(values)).toBe(720); + }); +}); diff --git a/src/pages/exercises/array-operations/_codes/js/response/array-operations.test.js b/src/pages/exercises/array-operations/_codes/js/response/array-operations.test.js index da05e7e3..1554562b 100644 --- a/src/pages/exercises/array-operations/_codes/js/response/array-operations.test.js +++ b/src/pages/exercises/array-operations/_codes/js/response/array-operations.test.js @@ -1,48 +1,59 @@ +import { describe, test } from 'node:test'; +import assert from 'node:assert'; import { sum, product, sumOdds } from './array-operations.js'; describe('Array Operation', () => { test('adding values from [1, 2, 3]', () => { let values = [1, 2, 3]; - expect(sum(values)).toBe(6); + + assert.equal(sum(values), 6); }); test('adding values from [2, 2, 2]', () => { let values = [2, 2, 2]; - expect(sum(values)).toBe(6); + + assert.equal(sum(values), 6); }); test('adding values from [1, 2, 3, 4, 5, 6]', () => { let values = [1, 2, 3, 4, 5, 6]; - expect(sum(values)).toBe(21); + + assert.equal(sum(values), 21); }); test('adding odd values from [1, 2, 3]', () => { let values = [1, 2, 3]; - expect(sumOdds(values)).toBe(4); + + assert.equal(sumOdds(values), 4); }); test('adding odd values from [2, 2, 2]', () => { let values = [2, 2, 2]; - expect(sumOdds(values)).toBe(0); + + assert.equal(sumOdds(values), 0); }); test('adding odd values from [1, 2, 3, 4, 5, 6]', () => { let values = [1, 2, 3, 4, 5, 6]; - expect(sumOdds(values)).toBe(9); + + assert.equal(sumOdds(values), 9); }); test('multiplying values from [1, 2, 3]', () => { let values = [1, 2, 3]; - expect(product(values)).toBe(6); + + assert.equal(product(values), 6); }); test('multiplying values from [2, 2, 2]', () => { let values = [2, 2, 2]; - expect(product(values)).toBe(8); + + assert.equal(product(values), 8); }); test('multiplying values from [1, 2, 3, 4, 5, 6]', () => { let values = [1, 2, 3, 4, 5, 6]; - expect(product(values)).toBe(720); + + assert.equal(product(values), 720); }); }); diff --git a/src/pages/exercises/array-operations/_codes/js/response/package.json b/src/pages/exercises/array-operations/_codes/js/response/package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/src/pages/exercises/array-operations/_codes/js/response/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +}