Skip to content

Commit

Permalink
fix(video-player): use static timestamps instead dynamic ones
Browse files Browse the repository at this point in the history
  • Loading branch information
square-li committed Dec 1, 2022
1 parent 3b59910 commit 1e434a6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ it('should return custom video progress bar html', () => {
// TimezoneOffset is included to make sure that output is calucalted as expected result without timezone issue during test
const timerangesWithSource = [
{
start: 1630005300000 + new Date().getTimezoneOffset() * 60000,
end: 1630005400000 + new Date().getTimezoneOffset() * 60000,
start: 1630005300000 + new Date(1630005300000).getTimezoneOffset() * 60000,
end: 1630005400000 + new Date(1630005400000).getTimezoneOffset() * 60000,
src: 'mockOnDemandURL-1',
},
{
start: 1630005400000 + new Date().getTimezoneOffset() * 60000,
end: 1630005500000 + new Date().getTimezoneOffset() * 60000,
start: 1630005400000 + new Date(1630005400000).getTimezoneOffset() * 60000,
end: 1630005500000 + new Date(1630005500000).getTimezoneOffset() * 60000,
src: 'mockOnDemandURL-2',
},
{
start: 1630005800000 + new Date().getTimezoneOffset() * 60000,
end: 1630005850000 + new Date().getTimezoneOffset() * 60000,
start: 1630005800000 + new Date(1630005800000).getTimezoneOffset() * 60000,
end: 1630005850000 + new Date(1630005850000).getTimezoneOffset() * 60000,
src: 'mockOnDemandURL-3',
},
];
const timerangesForVideoOnEdge = [
{
start: 1630005400000 + new Date().getTimezoneOffset() * 60000,
end: 1630005600000 + new Date().getTimezoneOffset() * 60000,
start: 1630005400000 + new Date(1630005400000).getTimezoneOffset() * 60000,
end: 1630005600000 + new Date(1630005600000).getTimezoneOffset() * 60000,
},
{
start: 1630005800000 + new Date().getTimezoneOffset() * 60000,
end: 1630005900000 + new Date().getTimezoneOffset() * 60000,
start: 1630005800000 + new Date(1630005800000).getTimezoneOffset() * 60000,
end: 1630005900000 + new Date(1630005900000).getTimezoneOffset() * 60000,
},
];
expect(
Expand All @@ -40,8 +40,8 @@ it('should return custom video progress bar html', () => {
playProgressId: 'playProgressId',
timerangesWithSource,
timerangesForVideoOnEdge,
startTimestamp: 1630005300000 + new Date().getTimezoneOffset() * 60000,
endTimestamp: 1630005900000 + new Date().getTimezoneOffset() * 60000,
startTimestamp: 1630005300000 + new Date(1630005300000).getTimezoneOffset() * 60000,
endTimestamp: 1630005900000 + new Date(1630005900000).getTimezoneOffset() * 60000,
})
).toEqual(expectedResult);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ it('should return start and end time for relative range in seconds', () => {
unit: 'second',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand All @@ -37,7 +37,7 @@ it('should return start and end time for relative range in minutes', () => {
unit: 'minute',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand All @@ -55,7 +55,7 @@ it('should return start and end time for relative range in hours', () => {
unit: 'hour',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand All @@ -73,7 +73,7 @@ it('should return start and end time for relative range in days', () => {
unit: 'day',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand All @@ -91,7 +91,7 @@ it('should return start and end time for relative range in week', () => {
unit: 'week',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand All @@ -109,7 +109,7 @@ it('should return start and end time for relative range in month', () => {
unit: 'month',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand All @@ -127,7 +127,7 @@ it('should return start and end time for relative range in year', () => {
unit: 'year',
type: 'relative',
};
const currentDateTimeForRelativeValue = new Date();
const currentDateTimeForRelativeValue = new Date(1665583620000);
const actualResult = getStartAndEndTimeFromRange(newDateRange, currentDateTimeForRelativeValue);

const endTime = currentDateTimeForRelativeValue.getTime().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ it('should return video seek time according to percentage', () => {

// TimezoneOffset is included to make sure that output is calucalted as expected result without timezone issue during test
it('should set valid tooltip on video progress', () => {
const seekTime = 1665583620000 + new Date().getTimezoneOffset() * 60000;
const startTime = 1665583520000 + new Date().getTimezoneOffset() * 60000;
const seekTime = 1665583620000 + new Date(1665583620000).getTimezoneOffset() * 60000;
const startTime = 1665583520000 + new Date(1665583520000).getTimezoneOffset() * 60000;
expect(getVideoProgressTooltip(seekTime, startTime)).toEqual(`10/12\n14:07:00`);
});

Expand Down

0 comments on commit 1e434a6

Please sign in to comment.