-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from Nefariusek/develop
Release version 2.0
- Loading branch information
Showing
119 changed files
with
3,560 additions
and
399 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Medication, { medicationValidator } from '../../models/Medication'; | ||
|
||
describe('Medication model test', () => { | ||
const date = new Date().getDay(); | ||
|
||
it('Medication with no given addDate has todays date', () => { | ||
const med = new Medication(); | ||
const addDate = med.addDate.getDay(); | ||
expect(addDate).toBe(date); | ||
}); | ||
}); | ||
|
||
describe('Joi validator for medication model', () => { | ||
let testRequestBody; | ||
let res; | ||
let err; | ||
beforeEach(() => { | ||
err = undefined; | ||
testRequestBody = { | ||
body: { | ||
nameOfMedication: undefined, | ||
quantity: undefined, | ||
addDate: undefined, | ||
dosage: undefined, | ||
expirationDate: undefined, | ||
}, | ||
}; | ||
}); | ||
|
||
it('Joi validator accepts allowed data', () => { | ||
testRequestBody.body.nameOfMedication = 'xanax'; | ||
testRequestBody.body.quantity = 2; | ||
testRequestBody.body.addDate = new Date(); | ||
testRequestBody.body.dosage = 'daily'; | ||
testRequestBody.body.expirationDate = new Date(); | ||
|
||
medicationValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).toBeUndefined(); | ||
}); | ||
|
||
it('Joi validator rejects wrong values', () => { | ||
testRequestBody.body.nameOfMedication = 'xa'; | ||
testRequestBody.body.quantity = 0; | ||
testRequestBody.body.addDate = 332; | ||
testRequestBody.body.dosage = '3'; | ||
testRequestBody.body.expirationDate = '01.02.2022'; | ||
|
||
medicationValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).not.toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import MedicationCategory, { medicationCategoryValidator } from '../../models/MedicationCategory'; | ||
import { PILLS_COLOR, SYRUP_COLOR } from '../../constants/MedicationCategory/pillColors'; | ||
import { QUANTITY_UNIT, VOLUME_UNIT } from '../../constants/MedicationCategory/medsUnits'; | ||
import { PILLS_ICON, SYRUP_ICON } from '../../constants/MedicationCategory/medsIcons'; | ||
import { PILL_MED_TYPE, SYRUP_MED_TYPE } from '../../constants/MedicationCategory/medTypes'; | ||
let testMedicationCategory; | ||
let testRequestBody; | ||
let res; | ||
let err; | ||
|
||
describe('MedicationCategory model', () => { | ||
beforeEach(() => { | ||
testMedicationCategory = new MedicationCategory(); | ||
}); | ||
|
||
it('new medication category has default values', () => { | ||
expect(testMedicationCategory.name).toBe(PILL_MED_TYPE); | ||
expect(testMedicationCategory.unit).toBe(QUANTITY_UNIT); | ||
expect(testMedicationCategory.color).toBe('blue'); | ||
expect(testMedicationCategory.icon).toBe(PILLS_ICON); | ||
}); | ||
|
||
it('settings model accepts allowed values', () => { | ||
testMedicationCategory.name = SYRUP_MED_TYPE; | ||
testMedicationCategory.unit = VOLUME_UNIT; | ||
testMedicationCategory.color = SYRUP_COLOR; | ||
testMedicationCategory.icon = SYRUP_ICON; | ||
|
||
expect(testMedicationCategory.name).toBe(SYRUP_MED_TYPE); | ||
expect(testMedicationCategory.unit).toBe(VOLUME_UNIT); | ||
expect(testMedicationCategory.color).toBe(SYRUP_COLOR); | ||
expect(testMedicationCategory.icon).toBe(SYRUP_ICON); | ||
}); | ||
}); | ||
|
||
describe('Joi validator for medication category model', () => { | ||
beforeEach(() => { | ||
err = undefined; | ||
testRequestBody = { | ||
body: { | ||
name: undefined, | ||
unit: undefined, | ||
color: undefined, | ||
icon: undefined, | ||
}, | ||
}; | ||
}); | ||
|
||
it('Joi validator accepts allowed data', () => { | ||
testRequestBody.body.name = SYRUP_MED_TYPE; | ||
testRequestBody.body.unit = VOLUME_UNIT; | ||
testRequestBody.body.color = SYRUP_COLOR; | ||
testRequestBody.body.icon = SYRUP_ICON; | ||
|
||
medicationCategoryValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).toBeUndefined(); | ||
}); | ||
|
||
it('Joi validator rejects wrong values', () => { | ||
let res; | ||
testRequestBody.body.name = 'Xa'; | ||
testRequestBody.body.unit = 'cm3'; | ||
testRequestBody.body.color = 'salmon'; | ||
testRequestBody.body.icon = 'not a valid icon'; | ||
|
||
medicationCategoryValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).not.toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Profile, { profileValidator } from '../../models/Profile'; | ||
|
||
let testRequestBody; | ||
let res; | ||
let err; | ||
const date = new Date().getDay(); | ||
const testString = 'abc'.repeat(61); | ||
const testDate = new Date().getDay() + 1; | ||
|
||
describe('Profile model test', () => { | ||
it('new profile has default last online value', () => { | ||
const profile = new Profile(); | ||
const addDate = profile.onlineDate.getDay(); | ||
expect(addDate).toBe(date); | ||
}); | ||
}); | ||
|
||
describe('Joi validator for profile model', () => { | ||
beforeEach(() => { | ||
err = undefined; | ||
testRequestBody = { | ||
body: { | ||
age: undefined, | ||
firstName: undefined, | ||
lastName: undefined, | ||
userBio: undefined, | ||
registerDate: undefined, | ||
onlineDate: undefined, | ||
}, | ||
}; | ||
}); | ||
|
||
it('Joi validator accepts allowed data', () => { | ||
testRequestBody.body.age = 5; | ||
testRequestBody.body.firstName = 'abcd'; | ||
testRequestBody.body.lastName = 'abcd'; | ||
testRequestBody.body.userBio = 'abcd'; | ||
testRequestBody.body.registerDate = date; | ||
testRequestBody.body.onlineDate = date; | ||
|
||
profileValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).toBeUndefined(); | ||
}); | ||
|
||
it('Joi validator rejects wrong values', () => { | ||
testRequestBody.body.age = 5.5; | ||
testRequestBody.body.firstName = 'ABCD'; | ||
testRequestBody.body.lastName = 'ABCD'; | ||
testRequestBody.body.userBio = testString; | ||
testRequestBody.body.registerDate = testDate; | ||
testRequestBody.body.onlineDate = testDate; | ||
|
||
profileValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).not.toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Settings, { settingsValidator } from '../../models/Settings'; | ||
import { LIGHT_THEME, DARK_THEME } from '../../constants/themes'; | ||
|
||
let testSettings; | ||
let testRequestBody; | ||
let res; | ||
let err; | ||
|
||
describe('Settings model', () => { | ||
beforeEach(() => { | ||
testSettings = new Settings(); | ||
}); | ||
|
||
it('new settings has default values', () => { | ||
expect(testSettings.appTheme).toBe(LIGHT_THEME); | ||
expect(testSettings.soonExpiringFilterLength).toBe(3); | ||
expect(testSettings.validateSync()).toBeUndefined(); | ||
}); | ||
|
||
it('settings model doesnt allow wrong values', () => { | ||
testSettings.appTheme = 'wrongAppTheme'; | ||
testSettings.soonExpiringFilterLength = 11; | ||
|
||
expect(testSettings.validateSync).toThrow(); | ||
}); | ||
|
||
it('settings model accepts allowed values', () => { | ||
testSettings.appTheme = DARK_THEME; | ||
testSettings.soonExpiringFilterLength = 5; | ||
|
||
expect(testSettings.appTheme).toBe(DARK_THEME); | ||
expect(testSettings.soonExpiringFilterLength).toBe(5); | ||
expect(testSettings.validateSync()).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('Joi validator for settings model', () => { | ||
beforeEach(() => { | ||
err = undefined; | ||
testRequestBody = { | ||
body: { | ||
appTheme: undefined, | ||
soonExpiringFilterLength: undefined, | ||
}, | ||
}; | ||
}); | ||
|
||
it('Joi validator accepts allowed data', () => { | ||
testRequestBody.body.appTheme = DARK_THEME; | ||
testRequestBody.body.soonExpiringFilterLength = 7; | ||
settingsValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).toBeUndefined(); | ||
}); | ||
|
||
it('Joi validator doesnt allow wrong values', () => { | ||
let res; | ||
testRequestBody.body.appTheme = 'wrongAppTheme'; | ||
testRequestBody.body.soonExpiringFilterLength = 4; | ||
settingsValidator(testRequestBody, res, (e) => { | ||
err = e; | ||
}); | ||
expect(err).not.toBeUndefined(); | ||
}); | ||
}); |
Oops, something went wrong.