-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
νμ¬ μν©
νλ‘μ νΈμ μ λ ν μ€νΈκ° μ ν μμ΅λλ€.
- ν μ€νΈ νλ μμν¬ λ―Έμ€μ
- ν΅μ¬ μ νΈλ¦¬ν° ν¨μλ€μ λμ κ²μ¦ λΆκ°
λͺ©ν
utils/ ν΄λμ ν΅μ¬ μ νΈλ¦¬ν° ν¨μμ λν μ λ ν
μ€νΈ μΆκ°
ν
μ€νΈ νμΌμ μ ν리μΌμ΄μ
μ½λ μμ λ°°μΉ (μ: github.js β github.test.js)
ν μ€νΈ λμ
utils/github.js
-
createJWT()- JWT μμ± λ° μλͺ -
importPrivateKey()- PKCS8 Private Key νμ± -
sign()- RS256 μλͺ μμ± -
base64UrlEncode()- Base64 URL μΈμ½λ©
utils/cors.js
-
corsResponse()- CORS ν€λ ν¬ν¨ μλ΅ -
errorResponse()- μλ¬ μλ΅ ν¬λ§·
νμΌ κ΅¬μ‘°
utils/
βββ github.js
βββ github.test.js # μλ‘ μΆκ°
βββ cors.js
βββ cors.test.js # μλ‘ μΆκ°
βββ webhook.js
βββ ... (κΈ°ν νμΌλ€)
ꡬν κ°μ΄λ
1. ν μ€νΈ νλ μμν¬ μ€μΉ
npm install -D vitest2. μ€μ νμΌ μμ±
vitest.config.js:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
},
});3. package.jsonμ μ€ν¬λ¦½νΈ μΆκ°
{
"scripts": {
"test": "vitest run",
"test:watch": "vitest"
}
}4. ν μ€νΈ νμΌ μμ± μμ
utils/github.test.js:
import { describe, it, expect } from 'vitest';
import { base64UrlEncode } from './github.js';
describe('base64UrlEncode', () => {
it('should encode Uint8Array to base64url', () => {
const input = new Uint8Array([72, 101, 108, 108, 111]);
const result = base64UrlEncode(input);
expect(result).toBe('SGVsbG8');
});
});utils/cors.test.js:
import { describe, it, expect } from 'vitest';
import { corsResponse, errorResponse } from './cors.js';
describe('corsResponse', () => {
it('should include CORS headers', () => {
const response = corsResponse({ success: true });
expect(response.headers.get('Access-Control-Allow-Origin')).toBe('*');
});
});
describe('errorResponse', () => {
it('should return error with status code', () => {
const response = errorResponse('Not found', 404);
expect(response.status).toBe(404);
});
});체ν¬λ¦¬μ€νΈ
- Vitest μ€μΉ
-
vitest.config.jsμμ± -
package.jsonμ test μ€ν¬λ¦½νΈ μΆκ° -
utils/github.test.jsμμ± -
utils/cors.test.jsμμ± -
npm testλ‘ λͺ¨λ ν μ€νΈ ν΅κ³Ό νμΈ
μ°Έκ³
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers