mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-23 02:34:36 -05:00
20 lines
825 B
TypeScript
20 lines
825 B
TypeScript
import { createGetAuthHeaderByURI } from '@pnpm/network.auth-header'
|
|
|
|
test('getAuthHeaderByURI()', () => {
|
|
const getAuthHeaderByURI = createGetAuthHeaderByURI({
|
|
allSettings: {
|
|
'//reg.com/:_authToken': 'abc123',
|
|
'//reg.co/tarballs/:_authToken': 'xxx',
|
|
},
|
|
userSettings: {},
|
|
})
|
|
expect(getAuthHeaderByURI('https://reg.com/')).toBe('Bearer abc123')
|
|
expect(getAuthHeaderByURI('https://reg.com/foo/-/foo-1.0.0.tgz')).toBe('Bearer abc123')
|
|
expect(getAuthHeaderByURI('https://reg.io/foo/-/foo-1.0.0.tgz')).toBe(undefined)
|
|
expect(getAuthHeaderByURI('https://reg.co/tarballs/foo/-/foo-1.0.0.tgz')).toBe('Bearer xxx')
|
|
})
|
|
|
|
test('returns undefined when the auth header is not found', () => {
|
|
expect(createGetAuthHeaderByURI({ allSettings: {}, userSettings: {} })('http://reg.com')).toBe(undefined)
|
|
})
|