From cd5819b62e5f05d5fa7d9254452fc246f6c2d745 Mon Sep 17 00:00:00 2001 From: Anna Headley Date: Mon, 15 May 2023 12:20:20 -0400 Subject: [PATCH] fix tests Co-authored-by: Trey Pendragon --- app/javascript/test/viewer/uv_manager.spec.js | 20 +++++++++++-------- app/javascript/viewer/uv_manager.js | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/javascript/test/viewer/uv_manager.spec.js b/app/javascript/test/viewer/uv_manager.spec.js index 5a1d26f025..cc97adfcfe 100644 --- a/app/javascript/test/viewer/uv_manager.spec.js +++ b/app/javascript/test/viewer/uv_manager.spec.js @@ -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 = '

' + @@ -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' @@ -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) } diff --git a/app/javascript/viewer/uv_manager.js b/app/javascript/viewer/uv_manager.js index cabe7ccccc..e49bc59c2f 100644 --- a/app/javascript/viewer/uv_manager.js +++ b/app/javascript/viewer/uv_manager.js @@ -242,7 +242,7 @@ export default class UVManager { } get iiifUrlAdapter () { - return new IIIFURLAdapter(); + return new IIIFURLAdapter() } get manifest () {