Skip to content

Commit

Permalink
Add test calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Misyukevich committed Jan 10, 2025
1 parent f39e55c commit faf2e71
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/calc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Calc

on:
push:
branches:
- main


jobs:
test_job:
runs-on: ubuntu-latest

steps:
- name: Checking the repository
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Start test
run: node testcalc.js
5 changes: 5 additions & 0 deletions calc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function sum(a, b) {
return a + b;
}

module.exports = sum;
25 changes: 25 additions & 0 deletions testcalc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const sum = require('./calc.js');

function testSum() {
console.log('Start testing the sum function');

if (sum(5, 4) === 9) {
console.log('Test 1 passed');
} else {
console.log('Test 1 failed')
}

if (sum(1, 1) === 2) {
console.log('Test 2 passed');
} else {
console.log('Test 2 failed')
}

if (sum(2, 2) === 5) {
console.log('Test 3 passed');
} else {
console.log('Test 3 failed')
}
}

testSum();

0 comments on commit faf2e71

Please sign in to comment.