Add label to timeline marker with current time.

This commit is contained in:
Dermot Duffy
2023-04-15 09:31:05 -07:00
parent 6ea7c7d260
commit 91f6f48696
4 changed files with 69 additions and 15 deletions
+20
View File
@@ -17,6 +17,7 @@ import {
prettifyTitle,
runWhenIdleIfSupported,
setify,
setOrRemoveAttribute,
sleep,
} from '../src/utils/basic';
@@ -131,6 +132,10 @@ describe('formatDateAndTime', () => {
const date = new Date(2023, 3, 14, 13, 35, 0);
expect(formatDateAndTime(date)).toBe('2023-04-14 13:35');
});
it('should format date and time with seconds', () => {
const date = new Date(2023, 3, 14, 13, 35, 1);
expect(formatDateAndTime(date, true)).toBe('2023-04-14 13:35:01');
});
});
describe('formatDate', () => {
@@ -220,3 +225,18 @@ describe('isValidDate', () => {
expect(isValidDate(new Date('moo'))).toBeFalsy();
});
});
describe('setOrRemoveAttribute', () => {
it('should set attribute', () => {
const element = document.createElement('div');
setOrRemoveAttribute(element, true, 'key', 'value');
expect(element.getAttribute('key')).toBe('value');
});
it('should remove attribute date', () => {
const element = document.createElement('div');
element.setAttribute('key', 'value');
setOrRemoveAttribute(element, false, 'key');
expect(element.getAttribute('key')).toBeFalsy();
});
});