Skip to content

Commit

Permalink
Attempt fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
cesardeazevedo committed Feb 4, 2025
1 parent 29c8610 commit 096ad48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nostr/__tests__/feeds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PaginationSubject } from '@/core/PaginationRangeSubject'
import { fakeEvent, fakeNote } from '@/utils/faker'
import { test } from '@/utils/fixtures'
import { subscribeSpyTo } from '@hirez_io/observer-spy'
import { delay, merge, take } from 'rxjs'
import { merge, take, takeUntil, timer } from 'rxjs'

describe('NostrFeeds', () => {
test('assert includeReplies', async ({ createMockRelay, createClient }) => {
Expand Down Expand Up @@ -48,11 +48,11 @@ describe('NostrFeeds', () => {
const pagination$ = new PaginationSubject({ kinds: [Kind.Text], authors: ['1'] })
const $ = client.feeds.self(pagination$, { includeParents: true, includeReplies: true })

const spy = subscribeSpyTo($.pipe(take(2)))
const spy = subscribeSpyTo($.pipe(takeUntil(timer(5000))))
await spy.onComplete()
await relay.close()
expect(spy.getValues()).toStrictEqual([note3, note1])
}, 35000)
})

test('assert following', async ({ createMockRelay, createClient }) => {
const note1 = fakeEvent({ id: '1', pubkey: '2', content: 'note' })
Expand All @@ -70,7 +70,7 @@ describe('NostrFeeds', () => {
includeReplies: false,
})
// needs a better way to complete the pagination subject
const spy = subscribeSpyTo(merge($.pipe(delay(2000), take(2))))
const spy = subscribeSpyTo(merge($.pipe(takeUntil(timer(5000)))))
await spy.onComplete()
await relay.close()

Expand Down

0 comments on commit 096ad48

Please sign in to comment.