* fix: logging information about the login * chore: improving the withBaseURL workflow * chore: moving VITE_KC_API_BASE_URL to the helper function * fix: env to helper function api base url * chore: fixing another api base url * chore: shortlinks with base api helper function * chore: prompt edit with base helper function * fix: auto fmt * fix: withAPIBaseURL for all urls * fix: AI caught my typo, RIP * fix: expected * fix: renaming this so it is less specific to environment --------- Co-authored-by: Jace Browning <jacebrowning@gmail.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { withAPIBaseURL } from '@src/lib/withBaseURL'
|
|
|
|
describe('withBaseURL', () => {
|
|
/**
|
|
* running in the development environment
|
|
* the .env.development should load
|
|
*/
|
|
describe('withAPIBaseUrl', () => {
|
|
it('should return base url', () => {
|
|
const expected = 'https://api.dev.zoo.dev'
|
|
const actual = withAPIBaseURL('')
|
|
expect(actual).toBe(expected)
|
|
})
|
|
it('should return base url with /users', () => {
|
|
const expected = 'https://api.dev.zoo.dev/users'
|
|
const actual = withAPIBaseURL('/users')
|
|
expect(actual).toBe(expected)
|
|
})
|
|
it('should return a longer base url with /oauth2/token/revoke', () => {
|
|
const expected = 'https://api.dev.zoo.dev/oauth2/token/revoke'
|
|
const actual = withAPIBaseURL('/oauth2/token/revoke')
|
|
expect(actual).toBe(expected)
|
|
})
|
|
it('should ensure base url does not have ending slash', () => {
|
|
const expected = 'https://api.dev.zoo.dev'
|
|
const actual = withAPIBaseURL('')
|
|
expect(actual).toBe(expected)
|
|
const expectedEndsWith = expected[expected.length - 1]
|
|
const actualEndsWith = actual[actual.length - 1]
|
|
expect(actual).toBe(expected)
|
|
expect(actualEndsWith).toBe(expectedEndsWith)
|
|
})
|
|
})
|
|
})
|