-
Notifications
You must be signed in to change notification settings - Fork 93
Module 1 exercises solved #53
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
Open
szucst
wants to merge
19
commits into
Idea-Pool:master
Choose a base branch
from
szucst:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ad49f40
euclidean and fibonacci js exercises completed
szucst b1f19e9
dependency changed for mocha
szucst bc3a1ce
classification exercise solved
szucst 539320d
Working on module2 exercises
szucst 6178b15
Working on module2 exercises - nr2
szucst 38d66fa
Modul 2 exercises solved
szucst 1a6e490
Mocha version changed back to the original
szucst f630e81
Rearranged comments in module2 calc.spec file
szucst 9ae4147
Module1 - solution for the classification exercise corrected
szucst cad9990
oop exercises solved and module-3 exercises started
szucst 0c9f2e1
oop tasks modified
szucst 43a34b5
oop tasks modified
szucst 999a55f
module 3 exercises completed
szucst 3c0c87b
Module 3 and OOP exercises modified and finished
szucst f3f40bd
Solving Module-4 exercises
szucst 183b591
Module 4 exercisese solved
szucst e28252f
Module 4 and Module 5 exercises
szucst 63d9a68
Plus/Async exercises solved
szucst f15be1e
Package.json new mocha scripts added
szucst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,5 +17,123 @@ describe.only('calc', () => { | |
| * .times(6).v // 24 | ||
| */ | ||
| // TODO: write test cases to test calculator | ||
|
|
||
| // constructor | ||
| it("should have a proper value", () => { | ||
| const c = calc(3); | ||
| expect(c).not.to.be.undefined; | ||
| }); | ||
|
|
||
| describe("add", () => { | ||
| // Checks If I have a calculator there is an "add" method as well? | ||
| // If the first IT fails within a describe, the other IT test cases won't be checked | ||
| it("should exist", () => { | ||
| const c = calc(3); | ||
| expect(c.add).not.to.be.undefined; | ||
| }); | ||
|
|
||
| it("should be able to add a number to the current value", () => { | ||
| // GIVEN | ||
| const c = calc(3); | ||
| // WHEN | ||
| const result = c.add(5).v; | ||
| // THEN | ||
| expect(result).to.equal(8); | ||
| }); | ||
| }); | ||
|
|
||
| describe("minus", () => { | ||
| it("should exist", () => { | ||
| const c = calc(3); | ||
| expect(c.minus).not.to.be.undefined; | ||
| }); | ||
|
|
||
| it("should be able to substract a number from the current value", () => { | ||
| const c = calc(3); | ||
| const result = c.minus(2).v; | ||
| expect(result).to.equal(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe("square", () => { | ||
| it("should exist", () => { | ||
| const c = calc(3); | ||
| expect(c.sqrt).not.to.be.undefined; | ||
| }); | ||
|
|
||
| it("should be able to get the square root of the current value", () => { | ||
| const c = calc(4); | ||
|
|
||
| const result = c.sqrt(2).v; | ||
|
|
||
| expect(result).to.be.equal(2); | ||
| }); | ||
|
|
||
| it("should handle square root with negative number", () => { | ||
| const c = calc(-4); | ||
|
|
||
| expect(() => c.sqrt()).to.throw("Square root of negative value cannot be determined!"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("times", () => { | ||
| it("should exist", () => { | ||
| const c = calc(3); | ||
| expect(c.times).not.to.be.undefined; | ||
| }); | ||
|
|
||
| it("should be able to multiply the current value with the given number", () => { | ||
| const c = calc(3); | ||
|
|
||
| const result = c.times(10).v; | ||
|
|
||
| expect(result).to.be.equal(30); | ||
| }); | ||
| }); | ||
|
|
||
| describe("divide", () => { | ||
| it("should exist", () => { | ||
| const c = calc(3); | ||
| expect(c.divide).not.to.be.undefined; | ||
| }); | ||
|
|
||
| it("should be able to divide the current value with the given number", () => { | ||
| const c = calc(10); | ||
|
|
||
| const result = c.divide(2).v; | ||
|
|
||
| expect(result).to.be.equal(5); | ||
| }); | ||
|
|
||
| it("should handle division by 0", () => { | ||
| const c = calc(42); | ||
| expect(() => c.divide(0)).to.throw("Division by 0 is not possible!"); | ||
| //expect(c.divide.bind(null, 0)).to.throw(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you still need the commented code snippet?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I don't need that many comments in my code. I changed it, and I left only the essential ones. |
||
| }); | ||
| }); | ||
|
|
||
| describe("modulo", () => { | ||
| it("should exist", () => { | ||
| const c = calc(3); | ||
| expect(c.modulo).not.to.be.undefined; | ||
| }); | ||
|
|
||
| it("should be able to get the modulo by dividing the current number with the given number", () => { | ||
| const c = calc(10); | ||
|
|
||
| const result = c.modulo(5).v; | ||
|
|
||
| expect(result).to.be.equal(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe("complexExpression", () => { | ||
| it("should be able to calculate the given more complex expression", () => { | ||
| const c = calc(3); | ||
|
|
||
| const result = c.add(4).minus(3).times(6).v; | ||
|
|
||
| expect(result).to.be.equal(24); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting of your code is inconsistent. Well-formatted code is easy to understand and important from maintenance perspective as well. Last but not least, looks cool. Please mind the formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you specify which part of the code is inconsistent?
I reviewed it and I don't see which code snippet is wrong.