Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Chai update #1798

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 156 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
"version": "8.5.0",
"description": "Proyectos y tópicos del curriculum del Bootcamp de @Laboratoria",
"repository": "Laboratoria/curriculum",
"type": "module",
"keywords": [
"javascript",
"laboratoria",
@@ -19,7 +20,7 @@
"scripts": {
"mdlint": "mdlint .",
"eslint": "eslint topics/",
"test:topics": "mocha './topics/!(node_modules)/**/*.spec.js' --verbose",
"test:topics": "mocha './topics/!(node_modules)/**/discount.spec.js' --verbose",
"test:scripts": "mocha './scripts/test/*.spec.mjs' --verbose",
"pretest": "npm run mdlint && npm run eslint && npm run validate && npm run test:topics",
"validate": "node ./scripts/build.mjs --validate",
@@ -64,7 +65,7 @@
"@testing-library/user-event": "^14.5.2",
"@vitejs/plugin-react": "^4.2.1",
"buffer": "^6.0.3",
"chai": "^4.4.1",
"chai": "^5.1.0",
"chokidar": "^3.6.0",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
1 change: 1 addition & 0 deletions topics/.eslintrc
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 0, "maxBOF": 0 }],
"jsx-a11y/href-no-hash": "off",
"jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }],
"import/extensions": "off",
"import/no-extraneous-dependencies": ["error", {
"devDependencies": [
"topics/javascript/**/*"
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@ const applyDiscount = (cart) => {
return [current].concat(applyDiscount(cart));
};

module.exports = applyDiscount;
export default applyDiscount;
Original file line number Diff line number Diff line change
@@ -43,4 +43,4 @@ const applyDiscount = (cart, discount) => {
// })].concat(applyDiscount(cart.slice(1), discount));


module.exports = applyDiscount;
export default applyDiscount;
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const Assert = require('chai').assert;
const Submission = require('../solution/discount');
import { assert } from 'chai';
import Submission from '../solution/discount.js';


describe('applyDiscount()', () => {
describe('applyDiscount() ', () => {

it('debería devolver un nuevo array', () => {
const cart = [];
const result = Submission(cart, .2);
Assert.notStrictEqual(cart, result);
assert.notStrictEqual(cart, result);
});

it('debería devolver un array con mismo length que input', () => {
[
[],
[{ price: 1 }],
[{ price: 1 }, { price: 7 }, { price: 19 }]
].forEach(cart => Assert.equal(cart.length, Submission(cart, .2).length));
].forEach(cart => assert.equal(cart.length, Submission(cart, .2).length));
});

it('no debería mutar array de entrada', () => {
@@ -24,13 +24,13 @@ describe('applyDiscount()', () => {
const item3 = { price: 3 };
const cart = [item1, item2, item3];
const cartWithDiscount = Submission(cart, .3);
Assert.strictEqual(cart.length, 3);
Assert.strictEqual(cart[0], item1);
Assert.strictEqual(cart[1], item2);
Assert.strictEqual(cart[2], item3);
Assert.deepEqual(cart[0], { price: 1 });
Assert.deepEqual(cart[1], { price: 2 });
Assert.deepEqual(cart[2], { price: 3 });
assert.strictEqual(cart.length, 3);
assert.strictEqual(cart[0], item1);
assert.strictEqual(cart[1], item2);
assert.strictEqual(cart[2], item3);
assert.deepEqual(cart[0], { price: 1 });
assert.deepEqual(cart[1], { price: 2 });
assert.deepEqual(cart[2], { price: 3 });
});

it('no debería mutar objetos', () => {
@@ -39,10 +39,10 @@ describe('applyDiscount()', () => {
const item3 = { price: 3 };
const cart = [item1, item2, item3];
const cartWithDiscount = Submission(cart, .3);
Assert.strictEqual(cart.length, 3);
Assert.strictEqual(cart[0].price, 1);
Assert.strictEqual(cart[1].price, 2);
Assert.strictEqual(cart[2].price, 3);
assert.strictEqual(cart.length, 3);
assert.strictEqual(cart[0].price, 1);
assert.strictEqual(cart[1].price, 2);
assert.strictEqual(cart[2].price, 3);
});

it('debería retornar objetos con descuento indicado', () => {
@@ -51,9 +51,9 @@ describe('applyDiscount()', () => {
const item3 = { price: 3 };
const cart = [item1, item2, item3];
const cartWithDiscount = Submission(cart, .3);
Assert.strictEqual(cartWithDiscount[0].price, 1 * (1 - .3));
Assert.strictEqual(cartWithDiscount[1].price, 2 * (1 - .3));
Assert.strictEqual(cartWithDiscount[2].price, 3 * (1 - .3));
assert.strictEqual(cartWithDiscount[0].price, 1 * (1 - .3));
assert.strictEqual(cartWithDiscount[1].price, 2 * (1 - .3));
assert.strictEqual(cartWithDiscount[2].price, 3 * (1 - .3));
});

});
Loading