Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
tests(State): Updating latitude and longititude
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarcosp committed Mar 25, 2020
1 parent c6ed517 commit cb981ed
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"env": {
"browser": true,
"es6": true
"es6": true,
"jest": true
},
"extends": [
"plugin:react/recommended",
Expand Down
7 changes: 3 additions & 4 deletions __tests__/unit/modules/brazil/spider.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path'
import BrazilSpider from '~/modules/brazil/spider'
import path from 'path'
import BrazilCrawler from '~/modules/brazil/crawler'
import { fromMockFile } from '../../../helpers/mock-crawler'

const pagePath = path.join(__dirname, 'mocks', 'page.html')
Expand All @@ -13,8 +13,7 @@ describe('[Unit]:: Global', () => {
totalRecovered,
activeCases,
closedCases
} = BrazilSpider.getData(document)

} = BrazilCrawler.getData(document)

expect(totalCases).toBe(529)
expect(totalDeaths).toBe(4)
Expand Down
6 changes: 3 additions & 3 deletions __tests__/unit/modules/global/spider.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path'
import GlobalSpider from '~/modules/global/spider'
import * as path from 'path'
import GlobalCrawler from '~/modules/global/crawler'
import { fromMockFile } from '../../../helpers/mock-crawler'

const pagePath = path.join(__dirname, 'mocks', 'page.html')
Expand All @@ -13,7 +13,7 @@ describe('[Unit]:: Global', () => {
totalRecovered,
activeCases,
closedCases
} = GlobalSpider.getData(document)
} = GlobalCrawler.getData(document)

expect(totalCases).toBe(219032)
expect(totalDeaths).toBe(8953)
Expand Down
50 changes: 25 additions & 25 deletions __tests__/unit/modules/states/services/finder.test.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import axios from 'axios'
import MockAdapter from 'axios-mock-adapter'
import { getStatesData } from '~/modules/states/services/finder'

import { getStatesData } from '~/modules/states/services/data-finder'
import { stateMocks } from './mocks/state-mocks'

const mockAxios = new MockAdapter(axios)

mockAxios.onGet('https://raw.githubusercontent.com/wcota/covid19br/master/cases-brazil-total.csv').reply(200, stateMocks)

const expected = [
{
uf: "SP",
name: "São Paulo",
cases: 459,
casesMS: 459,
casesNotConfirmedByMS: 0,
deaths: 15,
latitude: -9.48000405,
longitude: -35.83996769
},
{
uf: "RJ",
name: "Rio de Janeiro",
cases: 119,
casesMS: 119,
casesNotConfirmedByMS: 0,
deaths: 3,
latitude: -9.48000405,
longitude: -35.83996769
}
]

describe('[Unit]::StatesFinder', () => {
describe('getStatesData', () => {
it('Deve parsear o csv e retornar os dados continudos no mesmo', async done => {
const result = await getStatesData()
expect(result).toEqual(expect.arrayContaining(expected))
expect(result).toEqual(expect.arrayContaining([
expect.objectContaining({
uf: 'SP',
name: 'São Paulo',
cases: 459,
casesMS: 459,
casesNotConfirmedByMS: 0,
deaths: 15,
latitude: -23.55,
longitude: -46.64
}),
expect.objectContaining({
uf: 'RJ',
name: 'Rio de Janeiro',
cases: 119,
casesMS: 119,
casesNotConfirmedByMS: 0,
deaths: 3,
latitude: -22.84,
longitude: -43.15
})
]))

done()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const stateMocks = `country,state,totalCases,totalCasesMS,notConfirmedByM
Brazil,TOTAL,1213,1128,85,18,http://plataforma.saude.gov.br/novocoronavirus/
Brazil,SP,459,459,0,15,http://www.saopaulo.sp.gov.br/
Brazil,RJ,119,119,0,3,http://www.rj.gov.br/
`
`
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.19.0",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/modules/brazil/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { logger } from '~/common/logger'
import { fromURL, WORLD_METER_URL } from '~/common/spider'
import { BrazilCollection } from '~/config/database'

import BrazilSpider from './spider'
import BrazilSpider from './crawler'

export const findAndStoreData = async () => {
logger.info('Buscando informarções do Brasil')
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/modules/global/service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromURL, WORLD_METER_URL } from '~/common/spider'
import GlobalSpider from './spider'
import GlobalSpider from './crawler'
import { GlobalCollection } from '~/config/database'
import { logger } from '~/common/logger'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import Papa from 'papaparse'
import { states } from '~/modules/states/utils'
import { states } from '~/modules/states/states-informations'
import { State } from '../typeDefs/State'

const URL = 'https://raw.githubusercontent.com/wcota/covid19br/master/cases-brazil-total.csv'
Expand Down
2 changes: 1 addition & 1 deletion src/modules/states/services/update-states-data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatesCollection, db } from '~/config/database'
import { getStatesData } from './finder'
import { getStatesData } from './data-finder'
import { logger } from '~/common/logger'

export const findAndStoreData = async () => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": ".",
"baseUrl": "./",
"paths": {
"~/*": [
"./src/*"
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@
regexpp "^3.0.0"
tsutils "^3.17.1"

"@typescript-eslint/experimental-utils@2.25.0":
"@typescript-eslint/experimental-utils@2.25.0", "@typescript-eslint/experimental-utils@^2.5.0":
version "2.25.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.25.0.tgz#13691c4fe368bd377b1e5b1e4ad660b220bf7714"
integrity sha512-0IZ4ZR5QkFYbaJk+8eJ2kYeA+1tzOE1sBjbwwtSV85oNWYUBep+EyhlZ7DLUCyhMUGuJpcCCFL0fDtYAP1zMZw==
Expand Down Expand Up @@ -2165,6 +2165,13 @@ eslint-plugin-import@^2.20.1:
read-pkg-up "^2.0.0"
resolve "^1.12.0"

eslint-plugin-jest@^23.8.2:
version "23.8.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-23.8.2.tgz#6f28b41c67ef635f803ebd9e168f6b73858eb8d4"
integrity sha512-xwbnvOsotSV27MtAe7s8uGWOori0nUsrXh2f1EnpmXua8sDfY6VZhHAhHg2sqK7HBNycRQExF074XSZ7DvfoFg==
dependencies:
"@typescript-eslint/experimental-utils" "^2.5.0"

eslint-plugin-node@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.0.0.tgz#365944bb0804c5d1d501182a9bc41a0ffefed726"
Expand Down

0 comments on commit cb981ed

Please sign in to comment.