-
Notifications
You must be signed in to change notification settings - Fork 0
Add easterEggUtil with generateHappy() function (fix color CSS bug) #75
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
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/fix-generate-happy-function
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.
Draft
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8984cb3
Initial plan
Copilot 0295a13
Add easterEggUtil with generateHappy function (fix color bug)
Copilot 6e550c8
Update package/easterEggUtil/generateHappy/index.ts
klmhyeonwoo edacb53
Update package/easterEggUtil/generateHappy/index.test.ts
klmhyeonwoo 4506372
Add README documentation for generateHappy function
Copilot 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 hidden or 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 hidden or 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,79 @@ | ||
| import { describe, test, expect, vi, beforeEach, afterEach } from "vitest"; | ||
| import generateHappy from "."; | ||
|
|
||
| describe("generateHappy", () => { | ||
| let consoleLogSpy: ReturnType<typeof vi.spyOn>; | ||
|
|
||
| beforeEach(() => { | ||
| // console.logλ₯Ό spyλ‘ λ체νμ¬ νΈμΆ μ¬λΆλ₯Ό μΆμ ν©λλ€. | ||
| consoleLogSpy = vi.spyOn(console, "log").mockImplementation(() => {}); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| // κ° ν μ€νΈ ν spyλ₯Ό 볡μν©λλ€. | ||
| consoleLogSpy.mockRestore(); | ||
| }); | ||
|
|
||
| test("μ¬μ©μ μ μ λ©μμ§κ° μμ λ κΈ°λ³Έ λ©μμ§ μ€ νλλ₯Ό λ°νν΄μΌ νλ€", () => { | ||
| const result = generateHappy(); | ||
|
|
||
| const defaultMessages = [ | ||
| "Keep going β you're doing great! πͺ", | ||
| "Small steps lead to big changes. π±", | ||
| "Today is a good day to smile. π", | ||
| "You're closer than you think. π", | ||
| "Stay curious, stay kind. β¨", | ||
| "Progress, not perfection. π", | ||
| "You make the code better. π»β€οΈ", | ||
| "Breathe. You're doing your best. π€οΈ", | ||
| "Trust the process, enjoy the journey. π€οΈ", | ||
| "Every bug fixed is a victory. ππ", | ||
| ]; | ||
|
|
||
| expect(defaultMessages).toContain(result); | ||
| }); | ||
|
|
||
| test("μ¬μ©μ μ μ λ©μμ§λ₯Ό μ λ¬νλ©΄ ν΄λΉ λ©μμ§λ₯Ό λ°νν΄μΌ νλ€", () => { | ||
| const customMessage = "Custom happy message!"; | ||
| const result = generateHappy(customMessage); | ||
|
|
||
| expect(result).toBe(customMessage); | ||
| }); | ||
|
|
||
| test("console.logκ° νΈμΆλμ΄μΌ νλ€", () => { | ||
| generateHappy("Test message"); | ||
|
|
||
| expect(consoleLogSpy).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| test("console.logμ νμμ€ν¬νμ λ©μμ§κ° ν¬ν¨λμ΄μΌ νλ€", () => { | ||
| const testMessage = "Test message"; | ||
| generateHappy(testMessage); | ||
|
|
||
| expect(consoleLogSpy).toHaveBeenCalled(); | ||
| const [firstArg] = consoleLogSpy.mock.calls[0]; | ||
|
|
||
| // 첫 λ²μ§Έ μΈμμ νμμ€ν¬νμ λ©μμ§κ° ν¬ν¨λμ΄ μλμ§ νμΈ | ||
| expect(firstArg).toContain(testMessage); | ||
| expect(firstArg).toMatch(/\[\d{1,2}:\d{2}:\d{2}.*\]/); // νμμ€ν¬ν νμ νμΈ | ||
| }); | ||
|
|
||
| test("console.logμ μ¬λ°λ₯Έ μ€νμΌμ΄ μ μ©λμ΄μΌ νλ€", () => { | ||
| generateHappy("Test message"); | ||
|
|
||
| expect(consoleLogSpy).toHaveBeenCalled(); | ||
| const args = consoleLogSpy.mock.calls[0]; | ||
|
|
||
| // μ€νμΌ μΈμλ€μ΄ μ¬λ°λ₯΄κ² μ λ¬λμλμ§ νμΈ | ||
| expect(args[1]).toBe('color: #ff69b4; font-weight: bold;'); | ||
| expect(args[2]).toBe('color: #333; font-size: 14px;'); | ||
| }); | ||
|
|
||
| test("μ¬λ¬ λ² νΈμΆν΄λ μ μμ μΌλ‘ λμν΄μΌ νλ€", () => { | ||
| generateHappy("Message 1"); | ||
| generateHappy("Message 2"); | ||
| generateHappy(); | ||
|
|
||
| expect(consoleLogSpy).toHaveBeenCalledTimes(3); | ||
| }); | ||
| }); | ||
This file contains hidden or 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,32 @@ | ||
| /** | ||
| * κ°λ°μμκ² κ²©λ € λ©μμ§λ₯Ό μ½μμ μΆλ ₯νλ ν¨μμ λλ€. | ||
| * @param message μΆλ ₯ν μ¬μ©μ μ μ λ©μμ§ (μ ν μ¬ν) | ||
| * @returns {string} μΆλ ₯λ λ©μμ§ ν μ€νΈ | ||
| */ | ||
klmhyeonwoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export default function generateHappy(message?: string) { | ||
| const defaultMessages = [ | ||
| "Keep going β you're doing great! πͺ", | ||
| "Small steps lead to big changes. π±", | ||
| "Today is a good day to smile. π", | ||
| "You're closer than you think. π", | ||
| "Stay curious, stay kind. β¨", | ||
| "Progress, not perfection. π", | ||
| "You make the code better. π»β€οΈ", | ||
| "Breathe. You're doing your best. π€οΈ", | ||
| "Trust the process, enjoy the journey. π€οΈ", | ||
| "Every bug fixed is a victory. ππ", | ||
| ]; | ||
|
|
||
| const text = | ||
| message ?? | ||
| defaultMessages[Math.floor(Math.random() * defaultMessages.length)]; | ||
| const timestamp = new Date().toLocaleTimeString(); | ||
|
|
||
| console.log( | ||
| `%c[${timestamp}] %c${text}`, | ||
| 'color: #ff69b4; font-weight: bold;', | ||
| 'color: #333; font-size: 14px;' | ||
| ); | ||
|
|
||
| return text; | ||
| } | ||
This file contains hidden or 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 @@ | ||
| export { default as generateHappy } from "./generateHappy"; |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.