Skip to content

Commit

Permalink
Merge pull request #104 from ciatph/dev
Browse files Browse the repository at this point in the history
v1.3.6
  • Loading branch information
ciatph authored Aug 28, 2024
2 parents 6db1ec4 + 5aa8061 commit 8a7df8a
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 252 deletions.
76 changes: 76 additions & 0 deletions app/__tests__/classInitialization/customSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require('dotenv').config()
const path = require('path')

const ExcelFile = require('../../src/classes/excel')
const ExcelFactory = require('../../src/classes/excelfactory')
const ColorLog = require('../../src/classes/colorlog')
const logger = new ColorLog({ isBold: true })

const checkClass = require('./checkClass')
const config = require('./config.json')

// Classes loading the default local 10-day Excel file using a custom regions config
const LOCAL_SOURCE = {
excelFactory: new ExcelFactory({ settings: config }),

excelFile: new ExcelFile({
pathToFile: path.join(__dirname, '..', '..', 'data', 'day1.xlsx'),
settings: config
})
}

// Classes loading the remote 10-day Excel file using a custom regions config
const REMOTE_SOURCE = {
excelFile: new ExcelFile({
pathToFile: path.join(__dirname, 'excelfiledownload5.xlsx'),
url: process.env.EXCEL_FILE_URL,
settings: config
}),

excelFactory: new ExcelFactory({
url: process.env.EXCEL_FILE_URL,
settings: config
})
}

/* eslint-disable no-undef */
describe('Class intialization using CUSTOM config', () => {
beforeAll(async () => {
return await Promise.all([
REMOTE_SOURCE.excelFile.init(),
REMOTE_SOURCE.excelFactory.init()
])
})

it('should load LOCAL_SOURCE Excel file', () => {
jest.setTimeout(40000)
logger.log('[INIT]: Started loading using "CUSTOM" config on LOCAL file')

checkClass({
excelInstance: LOCAL_SOURCE.excelFactory,
classType: ExcelFactory
})

checkClass({
excelInstance: LOCAL_SOURCE.excelFile,
classType: ExcelFile
})
})

it('should load REMOTE_SOURCE Excel file', async () => {
jest.setTimeout(20000)
logger.log('[INIT]: Started loading using "CUSTOM" config on REMOTE file')

checkClass({
excelInstance: REMOTE_SOURCE.excelFactory,
isRemote: true,
classType: ExcelFactory
})

checkClass({
excelInstance: REMOTE_SOURCE.excelFile,
isRemote: true,
classType: ExcelFile
})
})
})
72 changes: 72 additions & 0 deletions app/__tests__/classInitialization/defaultSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
require('dotenv').config()
const path = require('path')

const ExcelFile = require('../../src/classes/excel')
const ExcelFactory = require('../../src/classes/excelfactory')
const ColorLog = require('../../src/classes/colorlog')
const logger = new ColorLog({ isBold: true })

const checkClass = require('./checkClass')

// Classes loading the default local 10-day Excel file using the default PAGASA seasonal config
const LOCAL_SOURCE = {
excelFactory: new ExcelFactory(),

excelFile: new ExcelFile({
pathToFile: path.join(__dirname, '..', '..', 'data', 'day1.xlsx')
})
}

// Classes loading the remote 10-day Excel file using the default PAGASA seasonal config
const REMOTE_SOURCE = {
excelFile: new ExcelFile({
pathToFile: path.join(__dirname, 'excelfiledownload4.xlsx'),
url: process.env.EXCEL_FILE_URL
}),

excelFactory: new ExcelFactory({
url: process.env.EXCEL_FILE_URL
})
}

/* eslint-disable no-undef */
describe('Class intialization using DEFAULT config', () => {
beforeAll(async () => {
return await Promise.all([
REMOTE_SOURCE.excelFile.init(),
REMOTE_SOURCE.excelFactory.init()
])
})

it('should load LOCAL_SOURCE Excel file', () => {
jest.setTimeout(40000)
logger.log('[INIT]: Started loading using "DEFAULT" config on LOCAL file')

checkClass({
excelInstance: LOCAL_SOURCE.excelFactory,
classType: ExcelFactory
})

checkClass({
excelInstance: LOCAL_SOURCE.excelFile,
classType: ExcelFile
})
})

it('should load REMOTE_SOURCE Excel file', async () => {
jest.setTimeout(20000)
logger.log('[INIT]: Started loading using "DEFAULT" config on REMOTE file')

checkClass({
excelInstance: REMOTE_SOURCE.excelFactory,
isRemote: true,
classType: ExcelFactory
})

checkClass({
excelInstance: REMOTE_SOURCE.excelFile,
isRemote: true,
classType: ExcelFile
})
})
})
122 changes: 0 additions & 122 deletions app/__tests__/classInitialization/fileLoading.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/__tests__/municipalities/createMunicipalityInstance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('dotenv')
require('dotenv').config()

const ColorLog = require('../../src/classes/colorlog')
const logger = new ColorLog({ color: ColorLog.COLORS.TEXT.YELLOW, isBold: true })
Expand Down
33 changes: 18 additions & 15 deletions app/__tests__/municipalities/municipalitiesCount.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('dotenv')
require('dotenv').config()
const path = require('path')

const ExcelFile = require('../../src/classes/excel')
Expand All @@ -9,26 +9,23 @@ const checkClass = require('../classInitialization/checkClass')
const createMunicipalityInstance = require('./createMunicipalityInstance')
const { arrayToString } = require('../../src/lib/utils')

// Test using the latest 10-day PAGASA Excel file
const excelFile = new ExcelFile({
pathToFile: path.join(__dirname, 'excelfiledownload.xlsx'),
url: process.env.EXCEL_FILE_URL
})

/* eslint-disable no-undef */
describe('Municipalities total count match', () => {
// Test using the latest 10-day PAGASA Excel file
const excelFile = new ExcelFile({
pathToFile: path.join(__dirname, 'excelfiledownload.xlsx'),
url: process.env.EXCEL_FILE_URL
beforeAll(async () => {
// Start file download
return await excelFile.init()
})

it('municipalities from provinces config should match with original Excel municipalities count', async () => {
jest.setTimeout(15000)

// Start file download
await excelFile.init()

checkClass({
excelInstance: excelFile,
isRemote: true,
classType: ExcelFile
})
jest.setTimeout(20000)

// Create local/remote ExcelFile classes using the default PAGASA region settings
const {
excel,
config,
Expand Down Expand Up @@ -85,6 +82,12 @@ describe('Municipalities total count match', () => {
})
}

checkClass({
excelInstance: excelFile,
isRemote: true,
classType: ExcelFile
})

/* Uncomment true "tests" for municipalities count match testing
expect(excel.countMunicipalities).toBe(config.countMunicipalities)
expect(excel.provinces.length).toBe(config.provinces.size)
Expand Down
Loading

0 comments on commit 8a7df8a

Please sign in to comment.