-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* JavaScript * Fix working directory * Fix directory * Fix
- Loading branch information
1 parent
ccd1c8a
commit cdad7b6
Showing
11 changed files
with
3,779 additions
and
1 deletion.
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,40 @@ | ||
name: JavaScript | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
paths: | ||
- javascript/** | ||
pull_request: | ||
branches: [ "main" ] | ||
paths: | ||
- javascript/** | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: javascript | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
cache: 'npm' | ||
cache-dependency-path: javascript/package-lock.json | ||
|
||
- name: Install | ||
run: npm install | ||
|
||
- name: Test | ||
run: npm test |
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 @@ | ||
node_modules |
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,15 @@ | ||
const HelloMessage = require("./HelloMessage.js"); | ||
const HelloConsole = require("./HelloConsole.js"); | ||
|
||
class HelloApp { | ||
constructor(helloMessage, helloConsole) { | ||
this.helloMessage = helloMessage; | ||
this.helloConsole = helloConsole; | ||
} | ||
|
||
printHello() { | ||
this.helloConsole.print(this.helloMessage.text); | ||
} | ||
} | ||
|
||
module.exports = HelloApp; |
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,26 @@ | ||
const HelloMessage = require("./HelloMessage"); | ||
const HelloConsole = require("./HelloConsole"); | ||
const HelloApp = require("./HelloApp"); | ||
|
||
jest.mock('./HelloMessage'); | ||
jest.mock('./HelloConsole'); | ||
|
||
describe('HelloApp', () => { | ||
it("should print hello message", () => { | ||
const helloMessageText = "Hello Test!"; | ||
HelloMessage.mockImplementation(() => { | ||
return { | ||
text: helloMessageText | ||
} | ||
}); | ||
const helloMessage = new HelloMessage(); | ||
|
||
const helloConsole = new HelloConsole(); | ||
|
||
const helloApp = new HelloApp(helloMessage, helloConsole); | ||
helloApp.printHello(); | ||
|
||
expect(helloConsole.print).toHaveBeenCalledTimes(1); | ||
expect(helloConsole.print).toHaveBeenCalledWith(helloMessageText); | ||
}) | ||
}); |
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,7 @@ | ||
class HelloConsole { | ||
print(text) { | ||
console.log(text); | ||
} | ||
} | ||
|
||
module.exports = HelloConsole |
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 @@ | ||
class HelloMessage { | ||
text = "Hello World!"; | ||
} | ||
|
||
module.exports = HelloMessage |
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,8 @@ | ||
const HelloMessage = require("./HelloMessage"); | ||
|
||
describe('HelloMessage', () => { | ||
it("should return hello world", () => { | ||
const helloMessage = new HelloMessage(); | ||
expect(helloMessage.text).toBe('Hello World!'); | ||
}) | ||
}); |
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,8 @@ | ||
const HelloMessage = require("./HelloMessage"); | ||
const HelloConsole = require("./HelloConsole"); | ||
const HelloApp = require("./HelloApp"); | ||
|
||
const helloMessage = new HelloMessage(); | ||
const helloConsole = new HelloConsole(); | ||
const helloApp = new HelloApp(helloMessage, helloConsole); | ||
helloApp.printHello(); |
Oops, something went wrong.