trim events' location, change variable name

This commit is contained in:
Daniel Waxweiler 2022-01-09 12:54:58 +01:00
parent ec12889815
commit 184d5627a3
3 changed files with 14 additions and 8 deletions

View File

@ -8,6 +8,7 @@
#### Removed
#### Fixed
- Use ES modules correctly
- Trim events' location
#### Security
### [0.7.0] - 2021-12-23

View File

@ -53,16 +53,21 @@ test('#formatDate second date is null with short offset name', (t) => {
})
test('#formatLocation both parameters', (t) => {
const date = Formatter.formatLocation({ description: 'a', locality: 'b' })
t.is(date, 'a, b')
const location = Formatter.formatLocation({ description: 'a', locality: 'b' })
t.is(location, 'a, b')
})
test('#formatLocation description only', (t) => {
const date = Formatter.formatLocation({ description: 'a' })
t.is(date, 'a')
const location = Formatter.formatLocation({ description: 'a' })
t.is(location, 'a')
})
test('#formatLocation description with space only', (t) => {
const location = Formatter.formatLocation({ description: ' ' })
t.is(location, '')
})
test('#formatLocation locality only', (t) => {
const date = Formatter.formatLocation({ locality: 'a' })
t.is(date, 'a')
const location = Formatter.formatLocation({ locality: 'a' })
t.is(location, 'a')
})

View File

@ -31,8 +31,8 @@ export default class Formatter {
static formatLocation({ description, locality }) {
let location = ''
if (description) {
location += description
if (description && description.trim()) {
location += description.trim()
}
if (location && locality) {
location += ', '