Skip to content

Commit

Permalink
teste do array-operation no js
Browse files Browse the repository at this point in the history
  • Loading branch information
luizchaves committed Mar 6, 2024
1 parent 49e9e78 commit 6cdfce5
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}

0 comments on commit 6cdfce5

Please sign in to comment.