Skip to content

Commit

Permalink
test(fix): custom dns-resolvers test
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Apr 17, 2024
1 parent 647b6cb commit 5cb5c8a
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions packages/verified-fetch/test/custom-dns-resolvers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import type { Helia } from '@helia/interface'
describe('custom dns-resolvers', () => {
let helia: Helia

beforeEach(async () => {
helia = await createHelia()
})

afterEach(async () => {
await stop(helia)
})
Expand All @@ -27,19 +23,19 @@ describe('custom dns-resolvers', () => {

const fetch = await createVerifiedFetch({
gateways: ['http://127.0.0.1:8080'],
routers: [],
dnsResolvers: [customDnsResolver]
})
const response = await fetch('ipns://some-non-cached-domain.com', { session: false })
const response = await fetch('ipns://some-non-cached-domain.com')
expect(response.status).to.equal(502)
expect(response.statusText).to.equal('Bad Gateway')

expect(customDnsResolver.callCount).to.equal(1)
expect(customDnsResolver.getCall(0).args[0]).to.equal('_dnslink.some-non-cached-domain.com')
expect(customDnsResolver.getCall(0).args[1]).to.deep.include({
expect(customDnsResolver.getCall(0).args).to.deep.equal(['_dnslink.some-non-cached-domain.com', {
types: [
RecordType.TXT
]
})
}])
})

it('is used when passed to VerifiedFetch', async () => {
Expand All @@ -62,17 +58,16 @@ describe('custom dns-resolvers', () => {
helia
})

const response = await verifiedFetch.fetch('ipns://some-non-cached-domain2.com', { session: false })
const response = await verifiedFetch.fetch('ipns://some-non-cached-domain2.com')
expect(response.status).to.equal(502)
expect(response.statusText).to.equal('Bad Gateway')

expect(customDnsResolver.callCount).to.equal(1)

expect(customDnsResolver.getCall(0).args[0]).to.equal('_dnslink.some-non-cached-domain2.com')
expect(customDnsResolver.getCall(0).args[1]).to.deep.include({
expect(customDnsResolver.getCall(0).args).to.deep.equal(['_dnslink.some-non-cached-domain2.com', {
types: [
RecordType.TXT
]
})
}])
})
})

0 comments on commit 5cb5c8a

Please sign in to comment.