Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions enhancer/enhancer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function success(item) {}

function fail(item) {
if (item.enhancement < 15 && item.durability < 25) {
return { ...item };
}
const durability =
item.enhancement < 15 ? item.durability - 5 : item.durability - 10;

return { ...item, durability };
}
function repair(item) {
return { ...item, durability: 100 };
}

module.exports = {
repair,
success,
fail,
};
48 changes: 48 additions & 0 deletions enhancer/enhancer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { success, repair, fail } = require('../enhancer/enhancer');

const item = {
name: 'sword',
type: 'weapon',
durability: 100,
enhancement: 17,
displayName: 'banana',
};
describe('enhancer', () => {
describe('fail()', () => {
it('durability decreases by 5 if enhanced is between 0 and 14', () => {
expect(fail({ enhancement: 14, durability: 85 }).durability).toBe(80);
});
it('durability decreases by 10 if greater than 14', () => {
//Arrange(setup)
const item = {
enhancement: 15,
durability: 85,
};
//Act - execute the system under test(SUT)
const actual = fail(item);
//Assert
expect(actual.durability).toBe(75);
});
it('If enhancement is 14 or lower, the item cannot be enhanced if the durability is below 25', () => {
const item = {
enhancement: 14,
durability: 24,
};
expect(fail(item)).toEqual(item);
});
});

//Repair
describe('repair()', () => {
it('sets durability to 100', () => {
expect(repair(item).durability).toEqual(100);
});
});
// //Success
// describe('Enhancement Success', () => {
// it('enhancement success', () => {
// expect(success(item).enhancement).toBe(17);
// console.log(item);
// });
// });
});
Empty file added enhancer/item.js
Empty file.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "testing-i",
"version": "1.0.0",
"description": "In this project, you will demonstrate proficiency by writing unit tests and production code to satisfy the _Minimum Viable Product_ described below.",
"main": "index.js",
"scripts": {
"test": "jest --watch --verbose"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Blent1050/testing-i.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Blent1050/testing-i/issues"
},
"homepage": "https://github.com/Blent1050/testing-i#readme",
"dependencies": {
"jest": "^24.1.0"
}
}
Loading