Skip to content

Commit

Permalink
Test/unit tests addition (#47) (#48)
Browse files Browse the repository at this point in the history
Test/unit tests addition (#47) (#48)
  • Loading branch information
jpmoura authored Jan 6, 2022
1 parent d950a52 commit 642c368
Show file tree
Hide file tree
Showing 49 changed files with 2,716 additions and 2,693 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
lib
dist
*.js
35 changes: 20 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"root": true,
"parser": "@typescript-eslint/parser",
"env": {
"jest/globals": true
},
"plugins": [
"@typescript-eslint",
"jest"
],
"extends": [
"airbnb-typescript/base",
"plugin:jest/all"
],
"parserOptions": {
"project": "tsconfig.json"
},
"rules": {
"class-methods-use-this": 0
}
"@typescript-eslint",
"jest"
],
"extends": [
"airbnb-typescript/base",
"plugin:jest/all",
"plugin:import/recommended"
],
"parserOptions": {
"project": "tsconfig.json"
},
"rules": {
"class-methods-use-this": 0,
"jest/require-hook": 0
}
}
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI Workflow

on:
push:
branches:
- master
- develop
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "tests/**"
- "package.json"
- "yarn.lock"
- "tsconfig*"
pull_request:
branches:
- master
- develop
paths:
- ".github/workflows/ci.yml"
- "src/**"
- "tests/**"
- "package.json"
- "yarn.lock"
- "tsconfig*"

jobs:
code_analysis:
name: "Code Analysis"
runs-on: ubuntu-latest

steps:
- name: "Checkout repository on branch ${{ github.ref }}"
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache packages
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: yarn

- name: Lint
run: yarn lint

- name: Test
shell: bash
run: |
yarn test:ci
- name: Build
run: |
yarn build
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ typings/
# SonarLint folder
/.scannerwork/

# SonarScanner properties
/sonar-project.properties
.vscode/launch.json

# Production files
/dist
*.db
33 changes: 27 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "typescript", "typescriptreact"],
"eslint.alwaysShowStatus": true,
}
"typescript.referencesCodeLens.enabled": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"typescript",
"typescriptreact"
],
"eslint.alwaysShowStatus": true,
"eslint.packageManager": "yarn",
"cSpell.language": "en,pt,pt_BR",
"files.associations": {
"*.env.dev": "env",
"*.env.prod": "env",
"*.env.prd": "env",
"*.env.example": "env",
},
"cSpell.words": [
"autoload",
"firstdown",
"inversify",
"rotowire",
"Rotowire",
"tslog"
]
}
11 changes: 0 additions & 11 deletions index.ts

This file was deleted.

10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'node',
transform: { '^.+\\.ts?$': 'ts-jest' },
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageDirectory: 'coverage',
reporters: ['default', 'jest-sonar'],
testRegex: '(/tests/unit-tests.*|(\\.|/)(test|spec))\\.[jt]sx?$',
};
47 changes: 32 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
{
"name": "nfl-telegram-bot",
"version": "2.1.4",
"version": "3.0.0",
"description": "A Telegram bot that provides the latest news about the NFL",
"repository": "github:jpmoura/nfl-news-for-telegram",
"main": "index.ts",
"main": "src/index.ts",
"packageManager": "[email protected]",
"engines": {
"node": ">= 12.0.0"
},
"scripts": {
"prestart": "yarn build",
"start": "node ./dist/index.js",
"tsc": "tsc",
"commit": "git-cz",
"sonar": "node sonar-project.js"
"prebuild": "npx rimraf dist",
"build": "npx tsc --project ./tsconfig.build.json",
"test": "jest",
"test:cov": "jest --coverage",
"test:ci": "yarn test:cov --maxWorkers=2",
"lint": "npx eslint --ext .ts src/ tests/"
},
"keywords": [
"NFL",
Expand All @@ -33,28 +41,37 @@
"axios": "^0.21.2",
"cheerio": "^1.0.0-rc.5",
"dotenv": "^6.1.0",
"inversify": "^6.0.1",
"nedb": "^1.8.0",
"node-schedule": "^1.3.0",
"reflect-metadata": "^0.1.13",
"telegraf": "^3.25.0",
"tslog": "^3.3.1",
"twit": "^2.2.11"
},
"devDependencies": {
"@types/cheerio": "^0.22.22",
"@types/dotenv": "^8.2.0",
"@types/faker": "^5.5.9",
"@types/inversify": "^2.0.33",
"@types/jest": "^27.0.3",
"@types/nedb": "^1.8.11",
"@types/node-schedule": "^1.3.1",
"@types/twit": "^2.2.28",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"commitizen": "^4.2.2",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.14.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint": "^8.6.0",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^25.3.4",
"faker": "^5.5.3",
"husky": "^4.3.4",
"jest": "^26.6.3",
"sonarqube-scanner": "^2.8.0",
"typescript": "^4.1.2"
"jest": "^27.4.7",
"jest-mock-extended": "^2.0.4",
"jest-sonar": "^0.2.12",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.2",
"typescript": "^4.5.4"
}
}
19 changes: 0 additions & 19 deletions sonar-project.js

This file was deleted.

9 changes: 9 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sonar.projectKey=jpmoura_nfl-news-for-telegram
sonar.organization=jpmoura-github
sonar.projectName=nfl-telegram-bot
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions="tests/**/*"
sonar.tests="tests"
sonar.testExecutionReportPaths="coverage/sonar-report.xml"
sonar.javascript.lcov.reportPaths="coverage/lcov.info"
101 changes: 0 additions & 101 deletions src/application/BotManager.ts

This file was deleted.

Loading

0 comments on commit 642c368

Please sign in to comment.