File tree Expand file tree Collapse file tree 9 files changed +3778
-269
lines changed Expand file tree Collapse file tree 9 files changed +3778
-269
lines changed Original file line number Diff line number Diff line change 10
10
branches :
11
11
- main
12
12
- staging
13
+ workflow_dispatch :
13
14
14
15
jobs :
15
- test :
16
+ question-service-tests :
17
+ runs-on : ubuntu-latest
18
+
19
+ steps :
20
+ - name : Checkout repository
21
+ uses : actions/checkout@v2
22
+
23
+ - name : Set up .env
24
+ env :
25
+ QUESTION_FIREBASE_CREDENTIAL_PATH : ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
26
+ JWT_SECRET : ${{ secrets.JWT_SECRET }}
27
+ run : |
28
+ cd ./apps/question-service
29
+
30
+ echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env
31
+ echo "JWT_SECRET=$JWT_SECRET" >> .env
32
+
33
+ - name : Set up credentials
34
+ env :
35
+ QUESTION_FIREBASE_JSON : ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
36
+ QUESTION_FIREBASE_CREDENTIAL_PATH : ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
37
+ run : |
38
+ cd ./apps/question-service
39
+ echo "$QUESTION_FIREBASE_JSON" > "./$QUESTION_FIREBASE_CREDENTIAL_PATH"
40
+
41
+ - name : Setup Go
42
+ uses : actions/setup-go@v5
43
+ with :
44
+ go-version : ' 1.23.x'
45
+
46
+ - name : Install Go dependencies
47
+ run : |
48
+ cd ./apps/question-service
49
+ go mod tidy
50
+
51
+ - name : Install firebase tools
52
+ run : curl -sL firebase.tools | bash
53
+
54
+ - name : Run Go tests with Firebase emulator
55
+ run : firebase emulators:exec --only firestore 'cd ./apps/question-service; go test ./...'
56
+
57
+ frontend-unit-tests :
58
+ runs-on : ubuntu-latest
59
+
60
+ steps :
61
+ - name : Checkout repository
62
+ uses : actions/checkout@v2
63
+
64
+ - name : Setup .env
65
+ run : |
66
+ cd ./apps/frontend
67
+ cp .env.example .env
68
+
69
+ - name : Set up Node.js
70
+ uses : actions/setup-node@v2
71
+ with :
72
+ node-version : ' 22'
73
+
74
+ - name : Install pnpm
75
+ run : npm i -g pnpm
76
+
77
+ - name : Install dependencies
78
+ run : |
79
+ cd ./apps/frontend
80
+ pnpm i
81
+
82
+ - name : Run tests
83
+ run : |
84
+ cd ./apps/frontend
85
+ pnpm test
86
+
87
+ test-docker-compose :
16
88
runs-on : ubuntu-latest
17
89
18
90
steps :
Original file line number Diff line number Diff line change
1
+ import { formatTime } from "@/utils/DateTime"
2
+
3
+ describe ( "datetime module" , ( ) => {
4
+ it ( "formats a time correctly" , ( ) => {
5
+ expect ( formatTime ( 10 ) ) . toBe ( "00:10" )
6
+ } ) ;
7
+ } )
8
+
9
+
Original file line number Diff line number Diff line change
1
+ import { GetQuestions } from "@/app/services/question"
2
+ import { getToken } from "@/app/services/login-store" ;
3
+
4
+ const TOKEN = 'mocktoken' ;
5
+
6
+ jest . mock ( "@/app/services/login-store" , ( ) => {
7
+ return {
8
+ __esModule : true ,
9
+ getToken : jest . fn ( ( ) => TOKEN )
10
+ } ;
11
+ } )
12
+
13
+ beforeEach ( ( ) => {
14
+ global . fetch = jest . fn ( ) . mockResolvedValue ( {
15
+ async json ( ) {
16
+ return { }
17
+ }
18
+ } ) ;
19
+ } )
20
+
21
+ describe ( "mock" , ( ) => {
22
+
23
+ it ( "mocks correctly" , async ( ) => {
24
+ await GetQuestions ( )
25
+ expect ( jest . mocked ( getToken ) . mock . calls ) . toEqual ( [ [ ] ] )
26
+ expect ( jest . mocked ( fetch ) . mock . calls [ 0 ] [ 1 ] ) . toEqual ( {
27
+ "headers" : {
28
+ "Authorization" : `Bearer ${ TOKEN } ` ,
29
+ } ,
30
+ "method" : "GET" ,
31
+ } )
32
+ } ) ;
33
+
34
+ } )
You can’t perform that action at this time.
0 commit comments