Skip to content

Commit 71e2d17

Browse files
committedApr 18, 2022
#181834892 Fix test and compile TS files into JS for server in /server/build directory
1 parent 931ed73 commit 71e2d17

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed
 

‎Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COPY --from=build /app/build build
2323
COPY *.json ./
2424
RUN npm ci --production
2525

26-
COPY --from=build /app/server ./server/
26+
COPY --from=build /app/server/build ./server/
2727

2828
EXPOSE 8999
2929

‎package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
"scripts": {
33
"start": "vite",
44
"build": "vite build",
5-
"build:server": "tsc -m commonjs --target esnext --esModuleInterop true server/*.ts",
6-
"run:server": "npm run build:server && node server/server",
7-
"test": "web-test-runner \"src/**/*.test.ts\"",
8-
"test:server": "web-test-runner \"server/**/*.test.ts\""
5+
"build:server": "tsc -m commonjs --target esnext --esModuleInterop true --outDir server/build server/*.ts",
6+
"run:server": "npm run build:server && node server/build/server",
7+
"test": "web-test-runner \"src/**/*.test.ts\" \"server/**/*.test.ts\""
98
},
109
"dependencies": {
1110
"cookie-parser": "^1.4.6",

‎server/Logger.test.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
import Logger from './Logger'
2-
import sinon, {stub} from 'sinon'
1+
import logger from './Logger'
2+
import {spy, stub} from 'sinon'
33
import {expect} from 'chai'
44

5-
const date = Date.parse('9 April 2020 16:30:00 GMT')
5+
describe('Logger', () => {
6+
const date = Date.parse('9 April 2020 16:30:00 GMT+3')
7+
68
beforeEach(() => {
79
stub(Date, 'now').returns(date)
810
})
911

10-
describe('Logger', () => {
1112
it('outputs error', async () => {
12-
const log = sinon.spy(console, 'error')
13-
Logger.error('an error')
14-
expect(log.calledWith('[2020-3-1 16:30] [ERROR] an error')).to.be.true
13+
const log = spy(console, 'error')
14+
logger.error('an error')
15+
expect(log).calledWith('[2020-04-09 16:30] [ERROR] an error')
1516
})
1617

1718
it('outputs info log', async () => {
18-
const log = sinon.spy(console, 'info')
19-
Logger.info('an info log')
20-
expect(log.calledWith('[2020-3-1 16:30] [INFO] an info log')).to.be.true
19+
const log = spy(console, 'info')
20+
logger.info('an info log')
21+
expect(log).calledWith('[2020-04-09 16:30] [INFO] an info log')
2122
})
2223

2324
it('outputs regular log', async () => {
24-
const log = sinon.spy(console, 'log')
25-
Logger.log('some kind of log')
26-
expect(log.calledWith('[2020-3-1 16:30] some kind of log')).to.be.true
25+
const log = spy(console, 'log')
26+
logger.log('some kind of log')
27+
expect(log).calledWith('[2020-04-09 16:30] some kind of log')
2728
})
2829
})

‎server/Logger.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class Logger {
1515
const date = new Date(Date.now())
1616
return `[${date.getFullYear()}-` +
1717
`${(date.getMonth() + 1) >= 10 ? date.getMonth() + 1 : `0${date.getMonth() + 1}`}-` +
18-
`${date.getDate()} ${date.getHours()}:` +
18+
`${(date.getDate() >= 10) ? date.getDate() : `0${date.getDate()}` } ` +
19+
`${date.getHours()}:` +
1920
`${(date.getMinutes() >= 10) ? date.getMinutes() : `0${date.getMinutes()}`}]`
2021
}
2122
}

‎tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "@tsconfig/svelte/tsconfig.json",
3-
"include": ["src", "types"],
3+
"include": ["src", "server", "types"],
44
"exclude": ["e2e"],
55
"compilerOptions": {
66
"module": "esnext",

0 commit comments

Comments
 (0)
Please sign in to comment.