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

Add testing for primitives, objects and tools #20

Merged
merged 9 commits into from
May 23, 2024
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and test
on:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
transform: {},
testEnvironment: "jsdom",
};
24 changes: 6 additions & 18 deletions js/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,21 @@ export class InfoBox {
}

isHere(mouseX, mouseY) {
if (
return (
mouseX > this.x &&
mouseX < this.x + this.width &&
mouseY > this.y &&
mouseY < this.y + this.height
) {
return true;
}

return false;
);
}

isVisible(x, y, width, height) {
if (
return (
x + width > this.x &&
x < this.x + this.width &&
y + height > this.y &&
y < this.y + this.height
) {
return true;
}

return false;
);
}
}

Expand Down Expand Up @@ -245,15 +237,11 @@ export class Link {
console.log("boxHeight: ", this.boxHeight);
*/

if (
return (
x + width > boxX &&
x < boxX + boxWidth &&
y + height > boxY &&
y < boxY + boxHeight
) {
return true;
}

return false;
);
}
}
Loading
Loading