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

fix: remove unneeded fetch tests #1960

Merged
merged 1 commit into from
Feb 22, 2023
Merged
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
76 changes: 0 additions & 76 deletions test/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,79 +269,3 @@ test('setRequestReferrerPolicyOnRedirect', nested => {
t.equal(request.referrerPolicy, initial)
})
})

test('determineRequestsReferrer', (t) => {
t.plan(7)

t.test('Should handle empty referrerPolicy', (tt) => {
tt.plan(2)
tt.equal(util.determineRequestsReferrer({}), 'no-referrer')
tt.equal(util.determineRequestsReferrer({ referrerPolicy: '' }), 'no-referrer')
})

t.test('Should handle "no-referrer" referrerPolicy', (tt) => {
tt.plan(1)
tt.equal(util.determineRequestsReferrer({ referrerPolicy: 'no-referrer' }), 'no-referrer')
})

t.test('Should return "no-referrer" if request referrer is absent', (tt) => {
tt.plan(1)
tt.equal(util.determineRequestsReferrer({
referrerPolicy: 'origin'
}), 'no-referrer')
})

t.test('Should return "no-referrer" if scheme is local scheme', (tt) => {
tt.plan(3)
const referrerSources = [
new URL('data:something'),
new URL('about:blank'),
new URL('blob:https://video_url')]

for (const source of referrerSources) {
tt.equal(util.determineRequestsReferrer({
referrerPolicy: 'origin',
referrer: source
}), 'no-referrer')
}
})

t.test('Should return "no-referrer" if the request referrer is neither client nor instance of URL', (tt) => {
tt.plan(4)
const requests = [
{ referrerPolicy: 'origin', referrer: 'string' },
{ referrerPolicy: 'origin', referrer: null },
{ referrerPolicy: 'origin', referrer: undefined },
{ referrerPolicy: 'origin', referrer: '' }
]

for (const request of requests) {
tt.equal(util.determineRequestsReferrer(request), 'no-referrer')
}
})

t.test('Should return referrer origin on referrerPolicy origin', (tt) => {
tt.plan(1)
const expectedRequest = {
referrerPolicy: 'origin',
referrer: new URL('http://example:12345@example.com')
}

tt.equal(util.determineRequestsReferrer(expectedRequest), expectedRequest.referrer.origin)
})

t.test('Should return referrer url on referrerPolicy unsafe-url', (tt) => {
tt.plan(1)
const expectedRequest = {
referrerPolicy: 'unsafe-url',
referrer: new URL('http://example:12345@example.com/hello/world')
}

const expectedReffererUrl = new URL(expectedRequest.referrer.href)

expectedReffererUrl.username = ''
expectedReffererUrl.password = ''

tt.equal(util.determineRequestsReferrer(expectedRequest), expectedReffererUrl.href)
})
})