forked from vergnet/application-amicale
Added first real test
This commit is contained in:
parent
96c9b57d92
commit
a4c38168ad
3 changed files with 20 additions and 11 deletions
|
@ -11,7 +11,8 @@
|
|||
"testc": "jest --coverage"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "react-native"
|
||||
"preset": "react-native",
|
||||
"setupFilesAfterEnv": ["jest-extended"]
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "~10.0.0",
|
||||
|
@ -46,6 +47,7 @@
|
|||
"devDependencies": {
|
||||
"babel-preset-expo": "^8.0.0",
|
||||
"jest": "^25.1.0",
|
||||
"jest-extended": "^0.11.5",
|
||||
"react-test-renderer": "^16.13.1"
|
||||
},
|
||||
"private": true
|
||||
|
|
|
@ -74,10 +74,12 @@ export default class PlanningEventManager {
|
|||
}
|
||||
|
||||
static isDescriptionEmpty (description: string) {
|
||||
return description
|
||||
.replace('<p>', '')
|
||||
.replace('</p>', '')
|
||||
.replace('<br>', '').trim() === '';
|
||||
if (description !== undefined && description !== null) {
|
||||
return description
|
||||
.replace('<p>', '')
|
||||
.replace('</p>', '')
|
||||
.replace('<br>', '').trim() === '';
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
import React from 'react';
|
||||
import PlanningEventManager from "../PlanningEventManager";
|
||||
|
||||
test('time test', () => {
|
||||
expect(PlanningEventManager.formatTime("1:2")).toBe("1:2");
|
||||
test('isDescriptionEmpty', () => {
|
||||
expect(PlanningEventManager.isDescriptionEmpty("")).toBeTrue();
|
||||
expect(PlanningEventManager.isDescriptionEmpty("<p></p>")).toBeTrue();
|
||||
expect(PlanningEventManager.isDescriptionEmpty("<p><br></p>")).toBeTrue();
|
||||
expect(PlanningEventManager.isDescriptionEmpty("<p><br>")).toBeTrue();
|
||||
expect(PlanningEventManager.isDescriptionEmpty(null)).toBeTrue();
|
||||
expect(PlanningEventManager.isDescriptionEmpty(undefined)).toBeTrue();
|
||||
expect(PlanningEventManager.isDescriptionEmpty("coucou")).toBeFalse();
|
||||
expect(PlanningEventManager.isDescriptionEmpty("<p>coucou</p>")).toBeFalse();
|
||||
});
|
||||
|
||||
test('time test 2', () => {
|
||||
expect(PlanningEventManager.formatTime("1:2")).toBe("2:2");
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue