diff --git a/test/search-backend/fulltext-search-backend.test.ts b/test/search-backend/fulltext-search-backend.test.ts index c12288e..06bd0de 100644 --- a/test/search-backend/fulltext-search-backend.test.ts +++ b/test/search-backend/fulltext-search-backend.test.ts @@ -75,6 +75,16 @@ describe('FulltextSearchBackend', () => { expect(urlConfig?.credentials).to.equal('include'); }); + it('includes scope param from URL if not provided', async () => { + window.location.search = `?scope=boop`; + + const backend = new FulltextSearchBackend(); + await backend.performSearch({ query: 'foo' }); + + const queryParams = new URL(urlCalled!.toString()).searchParams; + expect(queryParams.get('scope')).to.equal('boop'); + }); + it('includes caching param if provided', async () => { const cachingParam = JSON.stringify({ bypass: true }); const backend = new FulltextSearchBackend({ @@ -86,6 +96,17 @@ describe('FulltextSearchBackend', () => { expect(queryParams.get('caching')).to.equal(cachingParam); }); + it('includes caching param from URL if not provided', async () => { + const cachingParam = JSON.stringify({ bypass: true }); + window.location.search = `?caching=${cachingParam}`; + + const backend = new FulltextSearchBackend(); + await backend.performSearch({ query: 'foo' }); + + const queryParams = new URL(urlCalled!.toString()).searchParams; + expect(queryParams.get('caching')).to.equal(cachingParam); + }); + it('can enable debugging by default on all searches', async () => { const backend = new FulltextSearchBackend({ baseUrl: 'foo.bar', @@ -239,4 +260,20 @@ describe('FulltextSearchBackend', () => { window.fetch = fetchBackup; console.log = logBackup; }); + + it('includes verbose param from URL if not provided', async () => { + window.location.search = `?verbose=1`; + + const logBackup = console.log; + const logSpy = Sinon.spy(); + console.log = logSpy; + + const backend = new FulltextSearchBackend(); + await backend.performSearch({ query: 'foo' }); + + expect(logSpy.callCount).to.be.greaterThan(0); + expect(logSpy.args[0][0]).to.equal('\n\n***** RESPONSE RECEIVED *****'); + + console.log = logBackup; + }); }); diff --git a/test/search-backend/metadata-search-backend.test.ts b/test/search-backend/metadata-search-backend.test.ts index b7faed1..8a468fe 100644 --- a/test/search-backend/metadata-search-backend.test.ts +++ b/test/search-backend/metadata-search-backend.test.ts @@ -75,6 +75,16 @@ describe('MetadataSearchBackend', () => { expect(urlConfig?.credentials).to.equal('include'); }); + it('includes scope param from URL if not provided', async () => { + window.location.search = `?scope=boop`; + + const backend = new MetadataSearchBackend(); + await backend.performSearch({ query: 'foo' }); + + const queryParams = new URL(urlCalled!.toString()).searchParams; + expect(queryParams.get('scope')).to.equal('boop'); + }); + it('includes caching param if provided', async () => { const cachingParam = JSON.stringify({ bypass: true }); const backend = new MetadataSearchBackend({ @@ -86,6 +96,17 @@ describe('MetadataSearchBackend', () => { expect(queryParams.get('caching')).to.equal(cachingParam); }); + it('includes caching param from URL if not provided', async () => { + const cachingParam = JSON.stringify({ bypass: true }); + window.location.search = `?caching=${cachingParam}`; + + const backend = new MetadataSearchBackend(); + await backend.performSearch({ query: 'foo' }); + + const queryParams = new URL(urlCalled!.toString()).searchParams; + expect(queryParams.get('caching')).to.equal(cachingParam); + }); + it('can enable debugging by default on all searches', async () => { const backend = new MetadataSearchBackend({ baseUrl: 'foo.bar', @@ -239,4 +260,20 @@ describe('MetadataSearchBackend', () => { window.fetch = fetchBackup; console.log = logBackup; }); + + it('includes verbose param from URL if not provided', async () => { + window.location.search = `?verbose=1`; + + const logBackup = console.log; + const logSpy = Sinon.spy(); + console.log = logSpy; + + const backend = new MetadataSearchBackend(); + await backend.performSearch({ query: 'foo' }); + + expect(logSpy.callCount).to.be.greaterThan(0); + expect(logSpy.args[0][0]).to.equal('\n\n***** RESPONSE RECEIVED *****'); + + console.log = logBackup; + }); });