Skip to content

Commit

Permalink
added tests & refactored auth.js
Browse files Browse the repository at this point in the history
  • Loading branch information
marythedev committed Sep 26, 2023
1 parent d1b0906 commit 485f004
Show file tree
Hide file tree
Showing 15 changed files with 4,562 additions and 1,039 deletions.
46 changes: 22 additions & 24 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
module.exports = {
"env": {
"commonjs": true,
"es2021": true,
"node": true
env: {
commonjs: true,
es2021: true,
node: true,
jest: true,
},
extends: 'eslint:recommended',
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
},
"extends": "eslint:recommended",
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
}
}
],
parserOptions: {
ecmaVersion: 'latest',
},
rules: {},
};
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ jobs:

- name: Run ESLint
run: npm run lint

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install node dependencies and run Tests
# There are two ways to do this:
# 1. run: |
# - npm install
# - npm test
#2. Use `install-ci-test` to do it in a single command, see https://docs.npmjs.com/cli/v8/commands/npm-install-ci-test
run: npm install-ci-test
11 changes: 11 additions & 0 deletions env.jest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Environment variables for running the tests.
# This file can be committed to git (it won't contain secrets)

# HTTP Port (defaults to 8080)
PORT=8080

# Disable logs in tests. For more detail, change this to `debug`
LOG_LEVEL=silent

# .htpasswd file to use in testing
HTPASSWD_FILE=tests/.htpasswd
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');
const envFile = path.join(__dirname, 'env.jest');
require('dotenv').config({ path: envFile });

console.log(`Using LOG_LEVEL=${process.env.LOG_LEVEL}. Use 'debug' in env.jest for more detail`);

// See: https://jestjs.io/docs/configuration
module.exports = {
verbose: true,
testTimeout: 5000,
};
Loading

0 comments on commit 485f004

Please sign in to comment.