diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
new file mode 100644
index 0000000..a418a48
--- /dev/null
+++ b/.github/workflows/coverage.yml
@@ -0,0 +1,47 @@
+name: Coverage
+
+on:
+ push:
+ pull_request:
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ env:
+ CODECOV_TOKEN: 613992d7-a6fc-4f73-8b0f-bfbe632ff352
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Use Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: 16
+
+ - name: Install and Run Yarn
+ run: npm install -g yarn && cd app && yarn
+
+ - name: Install NYC
+ run: npm install -D nyc --save-dev -g
+
+ - name: Start Docker Containers
+ run: cd app && docker-compose -f "docker-compose.yaml" up -d --build
+
+ - name: Install Dependendcies
+ run: cd app && yarn install
+
+ - name: Run Tests and Generate Coverage Report
+ run: cd app && nyc npm run test && nyc report --reporter=text-lcov > coverage.lcov
+
+ - name: Codecov
+ uses: codecov/codecov-action@v2
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ flags: unittests
+ files: ./app/coverage.lcov
+
+ - name: Stop Docker Containers
+ run: cd app && docker-compose -f "docker-compose.yaml" down
diff --git a/README.md b/README.md
index 3100893..d392a6e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,12 @@
# ufabc-next-server
-[![Build Status](https://travis-ci.com/ufabc-next/ufabc-matricula-server.svg?branch=master)](https://travis-ci.com/ufabc-next/ufabc-matricula-server)
-[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c6cd37818d9c4ab6b244bfefd5b83597)](https://www.codacy.com/app/fesnt/ufabc-matricula-server?utm_source=github.com&utm_medium=referral&utm_content=ufabc-next/ufabc-matricula-server&utm_campaign=Badge_Grade)
-[![codecov](https://codecov.io/gh/ufabc-next/ufabc-matricula-server/branch/master/graph/badge.svg)](https://codecov.io/gh/ufabc-next/ufabc-matricula-server)
+ ![GitHub repo size](https://img.shields.io/github/repo-size/UFABCNextOps/ufabc-next-server)
+
+[![Build status](https://ci.appveyor.com/api/projects/status/lsob9vj7eyuejun2?svg=true)](https://ci.appveyor.com/project/JhonataSantana/ufabc-next-server)
+[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c97a33d865fb4b35b257b538f1661ad7)](https://www.codacy.com/gh/UFABCNextOps/ufabc-next-server/dashboard?utm_source=github.com&utm_medium=referral&utm_content=UFABCNextOps/ufabc-next-server&utm_campaign=Badge_Grade)
+[![codecov](https://codecov.io/gh/UFABCNextOps/ufabc-next-server/branch/master/graph/badge.svg?token=NTRX2LN5T0)](https://codecov.io/gh/UFABCNextOps/ufabc-next-server)
+
+
### Para executar o server
diff --git a/app/helpers/season/findIdeais.spec.js b/app/helpers/season/findIdeais.spec.js
index 17d759d..ef92e0b 100644
--- a/app/helpers/season/findIdeais.spec.js
+++ b/app/helpers/season/findIdeais.spec.js
@@ -3,69 +3,69 @@ const findIdeais = require('./findIdeais')
describe('helpers.season.findIdeais', function() {
- it('Should return first quad courses', function () {
- const expectedCourses = [
- 'BCM0506-15', // COMUNICACAO E REDES
- 'BCJ0203-15', // ELETROMAG
- 'BIN0406-15', // IPE
- 'BCN0405-15', // IEDO
- 'BIR0004-15', // EPISTEMOLOGICAS
- 'BHO0102-15', // DESENVOL. E SUSTE.
- 'BHO0002-15', // PENSA. ECONOMICO
- 'BHP0201-15', // TEMAS E PROBLEMAS
- 'BHO0101-15', // ESTADO E RELA
- 'BIR0603-15', // CTS
- 'BHQ0003-15', // INTEPRE. BRASIL
- 'BHQ0001-15', // IDENT.E CULTURA
- ]
- const date = new Date("2021-04-10")
- const func = findIdeais(date)
+ it('Should return first quad courses', function () {
+ const expectedCourses = [
+ 'BCM0506-15', // COMUNICACAO E REDES
+ 'BCJ0203-15', // ELETROMAG
+ 'BIN0406-15', // IPE
+ 'BCN0405-15', // IEDO
+ 'BIR0004-15', // EPISTEMOLOGICAS
+ 'BHO0102-15', // DESENVOL. E SUSTE.
+ 'BHO0002-15', // PENSA. ECONOMICO
+ 'BHP0201-15', // TEMAS E PROBLEMAS
+ 'BHO0101-15', // ESTADO E RELA
+ 'BIR0603-15', // CTS
+ 'BHQ0003-15', // INTEPRE. BRASIL
+ 'BHQ0001-15', // IDENT.E CULTURA
+ ]
+ const date = new Date('2021-04-10')
+ const func = findIdeais(date)
- expectedCourses.forEach(function (course,index) {
- assert.equal(course, func[index])
- })
+ expectedCourses.forEach(function (course,index) {
+ assert.equal(course, func[index])
})
+ })
- it('Should return second quad courses', function () {
- const expectedCourses = [
- 'BCM0504-15', // NI
- 'BCN0404-15', // GA
- 'BCN0402-15', // FUV
- 'BCJ0204-15', // FEMEC
- 'BCL0306-15', // BIODIVERSIDADE
- 'BCK0103-15', // QUANTICA
- 'BCL0308-15', // BIOQUIMICA
- 'BIQ0602-15', // EDS
- 'BHO1335-15', // FORMACAO SISTEMA INTERNACIONAL
- 'BHO1101-15', // INTRODUCAO A ECONOMIA
- 'BHO0001-15', // INTRODUCAO AS HUMANIDADES
- 'BHP0202-15', // PENSAMENTO CRITICO
- ]
- const date = new Date("2021-07-10")
- const func = findIdeais(date)
+ it('Should return second quad courses', function () {
+ const expectedCourses = [
+ 'BCM0504-15', // NI
+ 'BCN0404-15', // GA
+ 'BCN0402-15', // FUV
+ 'BCJ0204-15', // FEMEC
+ 'BCL0306-15', // BIODIVERSIDADE
+ 'BCK0103-15', // QUANTICA
+ 'BCL0308-15', // BIOQUIMICA
+ 'BIQ0602-15', // EDS
+ 'BHO1335-15', // FORMACAO SISTEMA INTERNACIONAL
+ 'BHO1101-15', // INTRODUCAO A ECONOMIA
+ 'BHO0001-15', // INTRODUCAO AS HUMANIDADES
+ 'BHP0202-15', // PENSAMENTO CRITICO
+ ]
+ const date = new Date('2021-07-10')
+ const func = findIdeais(date)
- expectedCourses.forEach(function (course,index) {
- assert.equal(course, func[index])
- })
+ expectedCourses.forEach(function (course,index) {
+ assert.equal(course, func[index])
})
+ })
- it('Should return third quad courses', function () {
- const expectedCourses = [
- 'BCJ0205-15', // FETERM
- 'BCM0505-15', // PI
- 'BCN0407-15', // FVV
- 'BCL0307-15', // TQ
- 'BCK0104-15', // IAM
- 'BIR0603-15', // CTS
- 'BHP0001-15', // ETICA E JUSTICA
- 'BHQ0301-15', // TERRITORIO E SOCIEDADE
- // ESTUDO ÉTNICOS RACIAIS
- ]
- const date = new Date("2021-11-21")
- const func = findIdeais(date)
+ it('Should return third quad courses', function () {
+ const expectedCourses = [
+ 'BCJ0205-15', // FETERM
+ 'BCM0505-15', // PI
+ 'BCN0407-15', // FVV
+ 'BCL0307-15', // TQ
+ 'BCK0104-15', // IAM
+ 'BIR0603-15', // CTS
+ 'BHP0001-15', // ETICA E JUSTICA
+ 'BHQ0301-15', // TERRITORIO E SOCIEDADE
+ // ESTUDO ÉTNICOS RACIAIS
+ ]
+ const date = new Date('2021-11-21')
+ const func = findIdeais(date)
- expectedCourses.forEach(function (course,index) {
- assert.equal(course, func[index])
- })
+ expectedCourses.forEach(function (course,index) {
+ assert.equal(course, func[index])
})
+ })
})
\ No newline at end of file
diff --git a/app/helpers/transform/resolveProfessor.spec.js b/app/helpers/transform/resolveProfessor.spec.js
new file mode 100644
index 0000000..060e1b8
--- /dev/null
+++ b/app/helpers/transform/resolveProfessor.spec.js
@@ -0,0 +1,33 @@
+const assert = require('assert')
+const resolveProfessor = require('./resolveProfessor.js')
+
+describe('helpers.transform.resolveProfessor', function() {
+
+ it('Should return Missing Teacher error', function () {
+ const professor = {'name': 'Paulo Meirelles'}
+ const profProcurado = {'name': 'Joaquin Melo'}
+
+ assert.throws(function() {
+ resolveProfessor(profProcurado, professor, {})
+ })
+ })
+
+ it('Should return null', function () {
+ const nullVariable = resolveProfessor('Falso', null, {})
+ assert.equal(nullVariable, null)
+ })
+
+ it('Should return a professor ', function () {
+ const professores = [
+ {name: 'Paulo Meirelles'}, {name: 'Joaquin Melo'},
+ {name: 'Fabio Carneiro'}, {name: 'Andre Rodrigues'},
+ {name: 'Igor Mourão'}, {name: 'Bruno Cruz'}]
+
+ const profProcurado = 'Joaquin Melo'
+
+ const profRetornado = resolveProfessor(profProcurado, professores, {})
+
+ assert.equal(profRetornado.name, 'Joaquin Melo')
+ })
+
+})
\ No newline at end of file
diff --git a/app/helpers/transform/transformMatriculas.spec.js b/app/helpers/transform/transformMatriculas.spec.js
new file mode 100644
index 0000000..940285f
--- /dev/null
+++ b/app/helpers/transform/transformMatriculas.spec.js
@@ -0,0 +1,21 @@
+const assert = require('assert')
+const transformMatriculas = require('./transformMatriculas.js')
+
+describe('helpers.transform.transformMatriculas ', function() {
+
+ it('Should concat student id in class', function () {
+ const disciplinas = {
+ '11066615': ['Funções de Uma Variável', 'Processamento da Informação',
+ 'Engenharia de Software', 'Física Quântica'],
+ '11075416': ['Funções de Uma Variável', 'Processamento da Informação',
+ 'Laboratório de Engenharia de Software', 'Fenônomenos Eletromagnéticos'],
+ '11000114': ['Funções de Uma Variável', 'Materiais e Suas Propriedades',
+ 'Teoria dos Grafos']}
+
+ const matriculas = transformMatriculas(disciplinas)
+
+ assert.equal(matriculas['Funções de Uma Variável'].length, 3)
+ assert.equal(matriculas['Processamento da Informação'].length, 2)
+ assert.equal(matriculas['Laboratório de Engenharia de Software'].length, 1)
+ })
+})
\ No newline at end of file
diff --git a/app/helpers/validate/teachers.spec.js b/app/helpers/validate/teachers.spec.js
new file mode 100644
index 0000000..25b269c
--- /dev/null
+++ b/app/helpers/validate/teachers.spec.js
@@ -0,0 +1,59 @@
+const assert = require('assert')
+
+const teachers = require('./teachers')
+
+describe('teachers', function () {
+ it('should return empty list when has not errors', function () {
+ const disciplinas = [
+ {
+ teoria: {
+ name: 'Vanessa Kruth',
+ error: null,
+ },
+ pratica: {
+ name: 'Vanessa Kruth',
+ error: null,
+ }
+ },
+ {
+ teoria: {
+ name: 'Isidro',
+ error: null,
+ },
+ pratica: {
+ name: 'Isidro',
+ error: null,
+ }
+ },
+ ];
+
+ assert.equal(0, Array.from(teachers(disciplinas)).length)
+ })
+
+ it('should return list with one error', function () {
+ const disciplinas = [
+ {
+ teoria: {
+ name: 'Vanessa Kruth',
+ error: null,
+ },
+ pratica: {
+ name: 'Vanessa Kruth',
+ error: null,
+ }
+ },
+ {
+ teoria: {
+ name: 'Isidro',
+ error: 'Sala não encontrada',
+ },
+ pratica: {
+ name: 'Isidro',
+ error: null,
+ }
+ },
+ ];
+
+ assert.equal(1, Array.from(teachers(disciplinas)).length)
+ })
+})
diff --git a/app/package.json b/app/package.json
index ef8aa05..c781b18 100644
--- a/app/package.json
+++ b/app/package.json
@@ -12,7 +12,7 @@
"start:watch": "apidoc -i api/ -o doc/ && forever --watch --watchFolder ./ ./server.js --colors",
"start:docker": "yarn build:docker && docker run -it -p 8010:8010 edu-web",
"populate": "node populate/index.js",
- "coverage": "NODE_ENV=test nyc yarn test && nyc report --reporter=text-lcov > coverage.lcov && codecov"
+ "coverage": "NODE_ENV=test nyc npm run test && nyc report --reporter=text-lcov > coverage.lcov"
},
"dependencies": {
"agenda": "^2.0.2",