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

feat/calculator - add calculator functionallity #118

Merged
merged 46 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5c59e5b
wip
nirtamir2 May 26, 2021
67e3d7a
wip
nirtamir2 May 26, 2021
9127663
wip
nirtamir2 May 28, 2021
9e9b761
add reducer
nirtamir2 Jun 3, 2021
c5f3b52
add tests
nirtamir2 Jun 4, 2021
a4f5efb
tests
nirtamir2 Jun 4, 2021
6200f7a
tests
nirtamir2 Jun 4, 2021
1710395
tests
nirtamir2 Jun 4, 2021
5016587
operator after equal fix
nirtamir2 Jun 4, 2021
af7ddc2
refactor
nirtamir2 Jun 5, 2021
9d3259f
rename
nirtamir2 Jun 5, 2021
ff9f9ff
tests
nirtamir2 Jun 5, 2021
974f31f
simplify tests
nirtamir2 Jun 14, 2021
a16d14e
fix +/-
nirtamir2 Jun 14, 2021
9e0c9e5
fix lock file
nirtamir2 Jun 17, 2021
8d09949
main deps
nirtamir2 Jun 17, 2021
225c846
my deps
nirtamir2 Jun 17, 2021
be99cc4
tdd - show first number
nirtamir2 Jun 17, 2021
5fdd7df
show first number with decimal point
nirtamir2 Jun 18, 2021
f4eb45b
show first number with decimal point
nirtamir2 Jun 18, 2021
8773dc1
refactor
nirtamir2 Jun 18, 2021
1a5e487
refactor - init number to 0
nirtamir2 Jun 18, 2021
010a87a
refactor
nirtamir2 Jun 18, 2021
8c1a91b
operator
nirtamir2 Jun 18, 2021
48793f1
equal
nirtamir2 Jun 18, 2021
5d68e12
equal
nirtamir2 Jun 18, 2021
eab660f
equal
nirtamir2 Jun 18, 2021
3da8ae5
multiple operator fixes
nirtamir2 Jun 18, 2021
31f3cd5
multi-operators
nirtamir2 Jun 18, 2021
86c2283
decimal math
nirtamir2 Jun 18, 2021
1f3abb0
refactor
nirtamir2 Jun 18, 2021
7fa6f3d
refactor
nirtamir2 Jun 18, 2021
536f016
decimal numbers math
nirtamir2 Jun 19, 2021
2f6d689
fix tests
nirtamir2 Jun 19, 2021
b8b2f53
operators
nirtamir2 Jun 19, 2021
e390dbf
enable replace operator
nirtamir2 Jun 19, 2021
5bbf786
reset equation on dot after =
nirtamir2 Jun 25, 2021
774a89e
+- operator
nirtamir2 Jun 26, 2021
6800db6
+- operator
nirtamir2 Jun 26, 2021
c32d55b
% operator
nirtamir2 Jun 26, 2021
91105b3
refactor unary operator
nirtamir2 Jun 26, 2021
3e0defe
better tests for firstNumberInput
nirtamir2 Jun 26, 2021
1387410
treat % as binary operator when second input
nirtamir2 Jun 26, 2021
ca6f9ca
test % with multiple =
nirtamir2 Jun 26, 2021
3e9374c
remove comment
nirtamir2 Jun 26, 2021
267c4ae
remove useless @testing-library
nirtamir2 Jun 26, 2021
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
Prev Previous commit
Next Next commit
tests
  • Loading branch information
nirtamir2 committed Jun 17, 2021
commit 6200f7a552b5bb83b59a5fab54f28cbee01a7319
16 changes: 15 additions & 1 deletion src/components/apps/Calculator/calculatorReducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ describe('calculator', () => {
handlePress(key);
expect(state.result).toBe(result);
}

handlePressReset();
}

function handlePressNumber(number: number) {
Expand Down Expand Up @@ -126,7 +128,19 @@ describe('calculator', () => {
test('Simple equations', () => {
testEquation([1, '+', 3, '='], ['1', '1', '3', '4']);
testEquation([5, 5, '+', 2, 3, '='], ['5', '55', '55', '2', '23', '78']);
// testEquation([1, 0, '+', 2, 4, '+', 5, '='], ['1', '10', '10', '2', '24', '34', '5', '39']);
});

test('Equations with more than one operator', () => {
testEquation([1, 0, '+', 2, 4, '+', 5, '='], ['1', '10', '10', '2', '24', '34', '5', '39']);
testEquation(
[1, 0, '+', 2, 4, '+', 5, '+', 1, 0, '='],
['1', '10', '10', '2', '24', '34', '5', '39', '1', '10', '49'],
);
});

test('Double equal should calculate same operator', () => {
testEquation([1, 0, '+', 2, 4, '=', '='], ['1', '10', '10', '2', '24', '34', '58']);
// testEquation([2, 4, '+', 1, 0, '=', '=', '='], ['2', '24', '24', '1', '10', '34', '44', '54']);
});
});

Expand Down
Loading