Skip to content

Commit

Permalink
Adjust unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jan 19, 2023
1 parent 161570e commit c085fc8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/web-runtime/tests/unit/helpers/theme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ describe('theme loading and error reporting', () => {

it('should load the default theme if location is empty', async () => {
const { theme } = await loadTheme()
expect(theme).toMatchObject(defaultTheme)
expect(theme).toMatchObject(defaultTheme.web)
})

it('should load the default theme if location is not a json file extension', async () => {
const { theme } = await loadTheme('some_location_without_json_file_ending.xml')
expect(theme).toMatchObject(defaultTheme)
expect(theme).toMatchObject(defaultTheme.web)
})

it('should load the default theme if location is not found', async () => {
fetch.mockResponse(new Error(), { status: 404 })
const { theme } = await loadTheme('http://www.owncloud.com/unknown.json')
expect(theme).toMatchObject(defaultTheme)
expect(theme).toMatchObject(defaultTheme.web)
})

it('should load the default theme if location is not a valid json file', async () => {
const customTheme = merge({}, defaultTheme, { default: { logo: { login: 'custom.svg' } } })
fetch.mockResponse(JSON.stringify(customTheme) + '-invalid')
const { theme } = await loadTheme('http://www.owncloud.com/invalid.json')
expect(theme).toMatchObject(defaultTheme)
expect(theme).toMatchObject(defaultTheme.web)
})

it('should load the default theme if server errors', async () => {
fetch.mockReject(new Error())
const { theme } = await loadTheme('http://www.owncloud.com')
expect(theme).toMatchObject(defaultTheme)
expect(theme).toMatchObject(defaultTheme.web)
})

it('should load the custom theme if a custom location is given', async () => {
const customTheme = merge({}, defaultTheme, { default: { logo: { login: 'custom.svg' } } })
const customTheme = merge({}, defaultTheme.web, { default: { logo: { login: 'custom.svg' } } })

fetch.mockResponse(JSON.stringify(customTheme))

Expand Down

0 comments on commit c085fc8

Please sign in to comment.