Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Co-authored-by: Trey Pendragon <[email protected]>
  • Loading branch information
hackartisan and tpendragon committed May 15, 2023
1 parent 7a45036 commit cd5819b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions app/javascript/test/viewer/uv_manager.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { init, IIIFURLAdapter } from "universalviewer";
import UVManager from 'viewer/uv_manager'
import jQ from 'jquery'
jest.mock('viewer/cdl_timer')
jest.mock('universalviewer', () => {
return {
__esModule: true,
init: jest.fn(),
IIIFURLAdapter: jest.fn().mockImplementation(() => {
return { get: global.getResult }
})
}
})

describe('UVManager', () => {
const initialHTML =
'<h1 id="title" class="lux-heading h1" style="display: none;"></h1>' +
Expand Down Expand Up @@ -57,7 +68,7 @@ describe('UVManager', () => {
}

function mockUvProvider (externalManifest = false, authToken = null) {
const getResult = jest.fn().mockImplementation(function (k) {
global.getResult = jest.fn().mockImplementation(function (k) {
if (k === 'manifest') {
if (externalManifest === true) {
return 'https://example.org/other/iiif/manifest'
Expand All @@ -73,13 +84,6 @@ describe('UVManager', () => {
} else { return null }
})

// This makes it so global.UV.URLDataProvider.get returns our mock data
const provider = jest.fn().mockImplementation(() => {
return { get: getResult }
})
global.UV = { URLDataProvider: provider }
global.createUV = jest.fn()
// Allow window location assign
jest.spyOn(window.location, 'assign').mockImplementation(() => true)
}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/viewer/uv_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class UVManager {
}

get iiifUrlAdapter () {
return new IIIFURLAdapter();
return new IIIFURLAdapter()
}

get manifest () {
Expand Down

0 comments on commit cd5819b

Please sign in to comment.