From f82259e03fc53d8274d154a864ccd7d871963926 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 +- spec/features/scanned_resource_spec.rb | 2 +- 3 files changed, 14 insertions(+), 10 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 () { diff --git a/spec/features/scanned_resource_spec.rb b/spec/features/scanned_resource_spec.rb index 5fe1ab71f0..859de95fb4 100644 --- a/spec/features/scanned_resource_spec.rb +++ b/spec/features/scanned_resource_spec.rb @@ -34,7 +34,7 @@ visit solr_document_path(id: resource.id) within_frame(find(".uv-container > iframe")) do - expect(page).to have_selector(".uv.en-gb") + expect(page).to have_selector(".uv-iiif-extension-host.en-gb") end end