trim events' location, change variable name
This commit is contained in:
parent
ec12889815
commit
184d5627a3
|
@ -8,6 +8,7 @@
|
|||
#### Removed
|
||||
#### Fixed
|
||||
- Use ES modules correctly
|
||||
- Trim events' location
|
||||
#### Security
|
||||
|
||||
### [0.7.0] - 2021-12-23
|
||||
|
|
|
@ -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')
|
||||
})
|
||||
|
|
|
@ -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 += ', '
|
||||
|
|
Loading…
Reference in New Issue