Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyLnd committed May 10, 2021
1 parent 763d937 commit 1b1e71c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/script/components/message/EphemeralTimer.test.ts
Expand Up @@ -32,18 +32,23 @@ class EphemeralTimerPage extends TestPage<EphemeralTimerProps> {
describe('EphemeralTimer', () => {
it('shows the icon', () => {
const message = new Message();
message.ephemeral_started(Date.now());
message.ephemeral_expires(new Date(new Date().getTime() + 10 * 60000).getTime());
const remaining = 600_000;
const now = Date.now();
message.ephemeral_started(now);
message.ephemeral_expires(now + remaining);
message.ephemeral_remaining(remaining);

const ephemeralTimer = new EphemeralTimerPage({message});
const circle = ephemeralTimer.getCircle();
expect(circle.props().style.animationDuration).toBe('600s');

expect(circle.props().style['--offset']).toBe(1);
});
it('hides the icon when no ephemeral timer was started', () => {
const message = new Message();

const ephemeralTimer = new EphemeralTimerPage({message});
const circle = ephemeralTimer.getCircle();
expect(circle.props().style.animationDuration).toBe('0s');

expect(circle.props().style['--offset']).toBe(0);
});
});
2 changes: 1 addition & 1 deletion src/script/components/message/EphemeralTimer.tsx
Expand Up @@ -44,7 +44,7 @@ const EphemeralTimer: React.FC<EphemeralTimerProps> = ({message}) => {
cx={4}
cy={4}
r={2}
style={{'--offset': remaining / duration} as React.CSSProperties}
style={{'--offset': remaining / duration || 0} as React.CSSProperties}
transform="rotate(-90 4 4)"
/>
</svg>
Expand Down

0 comments on commit 1b1e71c

Please sign in to comment.