forked from woowacourse/javascript-calculator
-
Notifications
You must be signed in to change notification settings - Fork 3
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
[yshin] javascript-calculator #3
Open
yhshin0
wants to merge
16
commits into
main
Choose a base branch
from
yshin
base: main
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
16 commits
Select commit
Hold shift + click to select a range
823a98e
docs: add test, env settings to README
2c7ed01
chore: eslint, prettier, cypress
ad9bc89
feat: add test case by cypress
c124ab2
feat: add class App
128e23a
feat: add class Equation
7f72ab5
feat: add click num
e517c81
chore: modify gitignore to exclude js
24f6ffa
feat: add calculate
60695f6
feat: add AC
24a0e8d
refactor: separate AC from constructor
17dce6d
refactor: separate typeNumber from constructor
fffa44a
refactor: separate clickOperation from constructor
14c710e
fix: click operation
b7e8393
fix: click number after calculating
af548d5
feat: remove click number test
c1a19a0
delete: index.js
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 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"airbnb-base" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
} | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
context("calculator", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:5500/"); | ||
}); | ||
|
||
it("calculator's first value", () => { | ||
cy.get("#total").should("have.text", 0); | ||
}); | ||
|
||
it("plus test", () => { | ||
// 123 + 234 = 357 | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".digit").contains(2).click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".operation").contains("+").click(); | ||
cy.get(".digit").contains(2).click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".digit").contains(4).click(); | ||
cy.get(".operation").contains("=").click(); | ||
cy.get("#total").should("have.text", 357); | ||
}); | ||
|
||
it("minus test", () => { | ||
// 234 - 123 = 111 | ||
cy.get(".digit").contains(2).click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".digit").contains(4).click(); | ||
cy.get(".operation").contains("-").click(); | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".digit").contains(2).click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".operation").contains("=").click(); | ||
cy.get("#total").should("have.text", 111); | ||
}); | ||
|
||
it("multiply test", () => { | ||
// 23 * 456 = 10488 | ||
cy.get(".digit").contains(2).click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".operation").contains("X").click(); | ||
cy.get(".digit").contains(4).click(); | ||
cy.get(".digit").contains(5).click(); | ||
cy.get(".digit").contains(6).click(); | ||
cy.get(".operation").contains("=").click(); | ||
cy.get("#total").should("have.text", 10488); | ||
}); | ||
|
||
it("divide test", () => { | ||
// 777 / 111 = 7 | ||
cy.get(".digit").contains(7).click(); | ||
cy.get(".digit").contains(7).click(); | ||
cy.get(".digit").contains(7).click(); | ||
cy.get(".operation").contains("/").click(); | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".operation").contains("=").click(); | ||
cy.get("#total").should("have.text", 7); | ||
}); | ||
|
||
it("AC test", () => { | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".digit").contains(2).click(); | ||
cy.get("button.modifier").click(); | ||
cy.get("#total").should("have.text", 0); | ||
}); | ||
|
||
it("max num test", () => { | ||
// 123 + 999 = 1122 | ||
cy.get(".digit").contains(1).click(); | ||
cy.get(".digit").contains(2).click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".digit").contains(9).click(); | ||
cy.get("#total").should("have.text", 123); | ||
cy.get(".operation").contains("+").click(); | ||
cy.get(".digit").contains(9).click(); | ||
cy.get(".digit").contains(9).click(); | ||
cy.get(".digit").contains(9).click(); | ||
cy.get(".digit").contains(9).click(); | ||
cy.get("#total").should("have.text", 999); | ||
cy.get(".operation").contains("=").click(); | ||
cy.get("#total").should("have.text", 1122); | ||
}); | ||
|
||
it("show only integer test", () => { | ||
// 50 / 3 = 16 | ||
cy.get(".digit").contains(5).click(); | ||
cy.get(".digit").contains(0).click(); | ||
cy.get(".operation").contains("/").click(); | ||
cy.get(".digit").contains(3).click(); | ||
cy.get(".operation").contains("=").click(); | ||
cy.get("#total").should("have.text", 16); | ||
}); | ||
}); |
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains 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 |
---|---|---|
@@ -1,38 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Calculator</title> | ||
<link rel="stylesheet" type="text/css" href="src/css/index.css" /> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<div class="calculator"> | ||
<h1 id="total">0</h1> | ||
<div class="digits flex"> | ||
<button class="digit">9</button> | ||
<button class="digit">8</button> | ||
<button class="digit">7</button> | ||
<button class="digit">6</button> | ||
<button class="digit">5</button> | ||
<button class="digit">4</button> | ||
<button class="digit">3</button> | ||
<button class="digit">2</button> | ||
<button class="digit">1</button> | ||
<button class="digit">0</button> | ||
</div> | ||
<div class="modifiers subgrid"> | ||
<button class="modifier">AC</button> | ||
</div> | ||
<div class="operations subgrid"> | ||
<button class="operation">/</button> | ||
<button class="operation">X</button> | ||
<button class="operation">-</button> | ||
<button class="operation">+</button> | ||
<button class="operation">=</button> | ||
</div> | ||
</div> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Calculator</title> | ||
<link rel="stylesheet" type="text/css" href="src/css/index.css" /> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<div class="calculator"> | ||
<h1 id="total">0</h1> | ||
<div class="digits flex"> | ||
<button class="digit">9</button> | ||
<button class="digit">8</button> | ||
<button class="digit">7</button> | ||
<button class="digit">6</button> | ||
<button class="digit">5</button> | ||
<button class="digit">4</button> | ||
<button class="digit">3</button> | ||
<button class="digit">2</button> | ||
<button class="digit">1</button> | ||
<button class="digit">0</button> | ||
</div> | ||
</body> | ||
<div class="modifiers subgrid"> | ||
<button class="modifier">AC</button> | ||
</div> | ||
<div class="operations subgrid"> | ||
<button class="operation">/</button> | ||
<button class="operation">X</button> | ||
<button class="operation">-</button> | ||
<button class="operation">+</button> | ||
<button class="operation">=</button> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="module" src="src/js/index.js"></script> | ||
</body> | ||
</html> |
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.
LGTM :) 👍👍