Skip to content

Commit

Permalink
[v0.1.43] Merge pull request #46 from mini-services/feature/add-test-…
Browse files Browse the repository at this point in the history
…to-validate-func

[WIP] set up tsconfig for tests, write first test for validate config (Happy flow)
  • Loading branch information
SnirShechter committed Jan 10, 2021
2 parents ae15533 + 54441f6 commit d0e5b1d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 11 deletions.
10 changes: 10 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@ export default {
timeout: '1m',
faileFast: true,
extensions: ['ts', 'js'],
nodeArguments: [
"--loader=ts-node/esm",
"--experimental-specifier-resolution=node"
],
extensions: {
"ts": "module"
},
nonSemVerExperiments: {
"configurableModuleFormat": true
},
}
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
version: v0.1.42
version: v0.1.43
name: miniurl
description: MiniUrl is an easy-to-use production-ready url shortener
home: https://github.com/SnirShechter/miniurl
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: miniservices/miniurl:v0.1.42
image: miniservices/miniurl:v0.1.43
imagePullPolicy: Always
port: 80
baseRedirectUrl:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "npm run test:unit && npm run test:e2e",
"start": "cross-env NODE_ENV=production node --loader ts-node/esm ./src/index.ts",
"dev": "env-cmd -f .env.development nodemon --watch \"src/**/*.ts\" --exec \"node --loader ts-node/esm --unhandled-rejections=strict --trace-warnings\" src/index.ts",
"test:unit": "ava",
"test:unit": "TS_NODE_PROJECT='./tsconfig-spec.json' ava",
"test:e2e": "exit 0"
},
"keywords": [
Expand Down
7 changes: 0 additions & 7 deletions src/config/__test__/validate.test.js

This file was deleted.

29 changes: 29 additions & 0 deletions src/config/__test__/validate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { validateConfig } from '../validate.js'
import test from 'ava'
import { RawConfig } from '../types.js'

const config: RawConfig = {
port: 'mock-port',
appName: 'mini-test',
baseRedirectUrl: 'http://mock.com',
url: {
matchPattern: 'mock-patter',
lifetime: '120',
},
storage: {
driverName: 'InMemory',
relationalDriverConfig: {
client: 'mock-client',
connection: {
host: 'local-host',
user: 'snir-hamair',
password: 'admin1234',
database: 'mock-db',
},
},
},
}

test('validate config - happy flow [configuration set propely]', (t) => {
t.is(validateConfig(config), true)
})
6 changes: 6 additions & 0 deletions tsconfig-spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true
"noImplicitReturns": true,
},
}

0 comments on commit d0e5b1d

Please sign in to comment.