@internetarchive/bookreader 5.0.0-44-a7 → 5.0.0-44

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 5.0.0-44
2
+ Fix: dynamic `q=<term>` url parameter @iisa
3
+ Fix: lcp download links @iisa
4
+ Dev: dependency updates @renovate
5
+
1
6
  # 5.0.0-43
2
7
  Fix: search results panel display asserted page numbers @cdrini
3
8
  Dev: dependency updates @renovate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-44-a7",
3
+ "version": "5.0.0-44",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -128,5 +128,40 @@ describe('Search Provider', () => {
128
128
  expect(urlPluginMock.pullFromAddressBar.callCount).toEqual(2);
129
129
  expect(urlPluginMock.removeUrlParam.callCount).toEqual(2);
130
130
  });
131
+ it('updateSearchInUrl', async () => {
132
+ let fieldToSet;
133
+ let valueOfFieldToSet;
134
+ let setUrlParamCalled = false;
135
+ const urlPluginMock = {
136
+ pullFromAddressBar: sinon.fake(),
137
+ removeUrlParam: sinon.fake(),
138
+ setUrlParam: (field, val) => {
139
+ fieldToSet = field;
140
+ valueOfFieldToSet = val;
141
+ setUrlParamCalled = true;
142
+ }
143
+ };
144
+ const provider = new searchProvider({
145
+ onProviderChange: sinon.fake(),
146
+ bookreader: {
147
+ leafNumToIndex: sinon.fake(),
148
+ _searchPluginGoToResult: sinon.fake(),
149
+ urlPlugin: urlPluginMock,
150
+ search: sinon.fake()
151
+ }
152
+ });
153
+
154
+ const searchInitiatedEvent = new CustomEvent('bookSearchInitiated', { detail: { query: 'foobar' } });
155
+ // set initial seachState with a query
156
+ provider.onBookSearchInitiated(searchInitiatedEvent);
157
+ await provider.updateComplete;
158
+ // checking this fn:
159
+ provider.updateSearchInUrl();
160
+ await provider.updateComplete;
161
+
162
+ expect(fieldToSet).toEqual('q');
163
+ expect(valueOfFieldToSet).toEqual('foobar');
164
+ expect(setUrlParamCalled).toBe(true);
165
+ });
131
166
  });
132
167
  });
@@ -236,4 +236,17 @@ describe('<ia-book-search-results>', () => {
236
236
 
237
237
  expect(response).toBeDefined();
238
238
  });
239
+ it('cancels search when input is cleared', async () => {
240
+ const el = await fixture(container(results));
241
+
242
+ el.cancelSearch = sinon.fake();
243
+ await el.updateComplete;
244
+
245
+ const searchInput = el.shadowRoot.querySelector('[name="query"]');
246
+
247
+ searchInput.value = '';
248
+ searchInput.dispatchEvent(new Event('search'));
249
+
250
+ expect(el.cancelSearch.callCount).toEqual(1);
251
+ });
239
252
  });