diff --git a/src/useSubscription/utilities/refresh.spec.ts b/src/useSubscription/utilities/refresh.spec.ts new file mode 100644 index 0000000..7172740 --- /dev/null +++ b/src/useSubscription/utilities/refresh.spec.ts @@ -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 () => { + 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) +}) \ No newline at end of file diff --git a/src/useSubscription/utilities/refresh.ts b/src/useSubscription/utilities/refresh.ts index 4537bc3..e6ddeb9 100644 --- a/src/useSubscription/utilities/refresh.ts +++ b/src/useSubscription/utilities/refresh.ts @@ -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( action: T, args: ActionArguments,