Compare commits

..

3 Commits

Author SHA1 Message Date
65cdee36e9 update testcase
All checks were successful
Compile the repository / compile (pull_request) Successful in 1m58s
2023-06-24 20:09:52 +02:00
6b0e84669a update dockerfile to support test stage 2023-06-24 20:09:09 +02:00
dd72f8e165 add automatic jest test in docker build to workflows 2023-06-24 20:09:00 +02:00
3 changed files with 34 additions and 5 deletions

View File

@ -0,0 +1,18 @@
name: Compile the repository
on: [pull_request]
env:
REGISTRY: gitea.brudi.xyz
IMAGE_NAME: ${{ gitea.repository }}
USER: ${{ gitea.actor }}
jobs:
compile:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Tests
run: docker build --target test .

View File

@ -1,11 +1,22 @@
FROM node:alpine as Build FROM node:alpine as files
ENV NODE_ENV=production
WORKDIR /app WORKDIR /app
COPY [ "package-lock.json", "package.json", "index.ts", "tsconfig.json", "./" ] COPY [ "package-lock.json", "package.json", "index.ts", "tsconfig.json", "./" ]
COPY server ./server COPY server ./server
FROM files as proddependencies
ENV NODE_ENV=production
RUN npm ci --omit=dev RUN npm ci --omit=dev
FROM proddependencies as compile
RUN npm run build RUN npm run build
CMD ["npm","run","start"] CMD ["npm","run","start"]
FROM files as dependencies
RUN npm ci
FROM dependencies as test
COPY jest.config.js .
COPY tests ./tests
RUN npm run test

View File

@ -10,7 +10,7 @@ function getTestDate(date: string): GuildScheduledEvent {
return <GuildScheduledEvent>{ scheduledStartAt: new Date(date) } return <GuildScheduledEvent>{ scheduledStartAt: new Date(date) }
} }
test('createDateStringFromEvent - correct formatting', () => { test('createDateStringFromEvent - correct formatting', () => {
expect(createDateStringFromEvent(getTestDate('01-01-2023 12:30'), "")).toEqual('heute um 12:30') expect(createDateStringFromEvent(getTestDate('01-01-2023 12:30'), "")).toEqual('heute um 13:30')
expect(createDateStringFromEvent(getTestDate('01-02-2023 12:30'), "")).toEqual('am Montag 02.01. um 12:30') expect(createDateStringFromEvent(getTestDate('01-02-2023 12:30'), "")).toEqual('am Montag 02.01 um 13:30')
expect(createDateStringFromEvent(getTestDate('01-03-2023 12:30'), "")).toEqual('am Dienstag 03.01 um 12:30') expect(createDateStringFromEvent(getTestDate('01-03-2023 12:30'), "")).toEqual('am Dienstag 03.01 um 13:30')
}) })