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

Sign up to get free protection for your applications and to get access to all the features.
@@ -102,66 +102,5 @@ describe('Search Provider', () => {
102
102
 
103
103
  expect(provider.bookreader._searchPluginGoToResult.callCount).toEqual(1);
104
104
  });
105
- test('update url when search is cancelled or input cleared', async() => {
106
- const urlPluginMock = {
107
- pullFromAddressBar: sinon.fake(),
108
- removeUrlParam: sinon.fake()
109
- };
110
- const provider = new searchProvider({
111
- onProviderChange: sinon.fake(),
112
- bookreader: {
113
- leafNumToIndex: sinon.fake(),
114
- _searchPluginGoToResult: sinon.fake(),
115
- urlPlugin: urlPluginMock
116
- }
117
- });
118
-
119
- provider.onSearchCanceled();
120
- await provider.updateComplete;
121
-
122
- expect(urlPluginMock.pullFromAddressBar.callCount).toEqual(1);
123
- expect(urlPluginMock.removeUrlParam.callCount).toEqual(1);
124
-
125
- provider.onSearchCanceled();
126
- await provider.updateComplete;
127
-
128
- expect(urlPluginMock.pullFromAddressBar.callCount).toEqual(2);
129
- expect(urlPluginMock.removeUrlParam.callCount).toEqual(2);
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
- });
166
105
  });
167
106
  });
@@ -236,17 +236,4 @@ 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
- });
252
239
  });