Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fschade committed Nov 4, 2021
1 parent 8d8553d commit 23c2b50
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The app provider extension should be able to load an iFrame via get 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<main class="uk-height-viewport">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<loadingscreen-stub></loadingscreen-stub>
<!---->
<!----> <iframe src="https://example.test/d12ab86/loe009157-MzBw" title="&quot;exampleApp&quot; app content area" class="uk-width-1-1 uk-height-viewport"></iframe>
<!---->
</main>
`;

exports[`The app provider extension should be able to load an iFrame via post 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<main class="uk-height-viewport">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<loadingscreen-stub></loadingscreen-stub>
<!---->
<!---->
<div>
<form action="https://example.test/d12ab86/loe009157-MzBw" target="app-iframe" method="post"><input type="submit" class="oc-hidden" value="[object Object]">
<div><input name="access_token" type="hidden" value="asdfsadfsadf"></div>
<div><input name="access_token_ttl" type="hidden" value="123456"></div>
</form> <iframe name="app-iframe" title="&quot;exampleApp&quot; app content area" class="uk-width-1-1 uk-height-viewport"></iframe>
</div>
</main>
`;
exports[`The app provider extension should fail for unauthenticated users 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<loadingscreen-stub></loadingscreen-stub>
<errorscreen-stub></errorscreen-stub>
<!---->
<!---->
</main>
Expand All @@ -39,7 +43,7 @@ exports[`The app provider extension should show a loading spinner while loading
exports[`The app provider extension should show a meaningful message if an error occurs during loading 1`] = `
<main class="uk-height-viewport uk-flex uk-flex-center uk-flex-middle">
<h1 class="oc-invisible-sr">"exampleApp" app page</h1>
<loadingscreen-stub></loadingscreen-stub>
<errorscreen-stub></errorscreen-stub>
<!---->
<!---->
</main>
Expand Down
11 changes: 8 additions & 3 deletions packages/web-app-external/tests/unit/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const componentStubs = {
}

const $route = {
query: {
'public-token': 'a-token'
},
params: {
app: 'exampleApp',
file_id: '2147491323'
Expand All @@ -30,6 +33,7 @@ const storeOptions = {
configuration: jest.fn(() => ({
server: 'http://example.com/'
})),
userReady: () => true,
capabilities: jest.fn(() => ({
files: {
app_providers: [
Expand Down Expand Up @@ -84,7 +88,7 @@ describe('The app provider extension', () => {
fetchMock.resetMocks()
})

it('should show a loading spinner while loading', () => {
it('should show a loading spinner while loading', async () => {
global.fetch = jest.fn(() =>
setTimeout(() => {
Promise.resolve({
Expand All @@ -94,19 +98,21 @@ describe('The app provider extension', () => {
}, 500)
)
const wrapper = createShallowMountWrapper()

await wrapper.vm.$nextTick()
expect(wrapper).toMatchSnapshot()
})
it('should show a meaningful message if an error occurs during loading', async () => {
fetchMock.mockReject(new Error('fake error message'))
const wrapper = createShallowMountWrapper()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(wrapper).toMatchSnapshot()
})
it('should fail for unauthenticated users', async () => {
fetchMock.mockResponseOnce({ status: 401 })
const wrapper = createShallowMountWrapper()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
expect(wrapper).toMatchSnapshot()
})
it('should be able to load an iFrame via get', async () => {
Expand All @@ -131,7 +137,6 @@ describe('The app provider extension', () => {
json: () => providerSuccessResponsePost
})
)

const wrapper = createShallowMountWrapper()
await wrapper.vm.$nextTick()
await wrapper.vm.$nextTick()
Expand Down

0 comments on commit 23c2b50

Please sign in to comment.