[Enhancement] Group widget messages by date (#363)
* [Enhancement] Group widget messages by date * Update DateSeparator snapshot
This commit is contained in:
13
app/javascript/shared/helpers/DateHelper.js
Normal file
13
app/javascript/shared/helpers/DateHelper.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import moment from 'moment';
|
||||
|
||||
class DateHelper {
|
||||
constructor(date) {
|
||||
this.date = moment(date * 1000);
|
||||
}
|
||||
|
||||
format(dateFormat = 'MMM DD, YYYY') {
|
||||
return this.date.format(dateFormat);
|
||||
}
|
||||
}
|
||||
|
||||
export default DateHelper;
|
||||
13
app/javascript/shared/helpers/specs/DateHelper.sepc.js
Normal file
13
app/javascript/shared/helpers/specs/DateHelper.sepc.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import DateSeparator from '../DateSeparator';
|
||||
|
||||
describe('#DateSeparator', () => {
|
||||
it('should format correctly without dateFormat', () => {
|
||||
expect(new DateSeparator(1576340626).format()).toEqual('Dec 14, 2019');
|
||||
});
|
||||
|
||||
it('should format correctly without dateFormat', () => {
|
||||
expect(new DateSeparator(1576340626).format('DD-MM-YYYY')).toEqual(
|
||||
'14-12-2019'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user