Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Add a test for refresh channel #406

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/useSubscription/utilities/refresh.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test, vi } from 'vitest'
import { SubscriptionManager } from '@/useSubscription/models'
import { useSubscription } from '@/useSubscription/useSubscription'
import { refreshChannel } from '@/useSubscription/utilities/refresh'

test('channel refreshes only when channel is active', async () => {

Check warning on line 6 in src/useSubscription/utilities/refresh.spec.ts

View workflow job for this annotation

GitHub Actions / ESLint

Async arrow function has no 'await' expression
const action = vi.fn()
const manager = new SubscriptionManager()
const subscription = useSubscription(action, [], { manager })

refreshChannel(action, [], { manager })

subscription.unsubscribe()

refreshChannel(action, [], { manager })

expect(action).toBeCalledTimes(2)
})
1 change: 0 additions & 1 deletion src/useSubscription/utilities/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Action, ActionArguments } from '@/useSubscription/types/action'
import { RefreshChannelOptions } from '@/useSubscription/types/channels'
import { defaultSubscriptionManager } from '@/useSubscription/useSubscription'


export function refreshChannel<T extends Action>(
action: T,
args: ActionArguments<T>,
Expand Down
Loading