@internetarchive/ia-item-navigator 0.0.0-a12 → 0.0.0-a13
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +29 -19
- package/demo/app-root.ts +31 -27
- package/demo/index.html +1 -0
- package/dist/demo/app-root.d.ts +11 -14
- package/dist/demo/app-root.js +25 -23
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/interfaces/menu-interfaces.d.ts +3 -2
- package/dist/src/interfaces/menu-interfaces.js.map +1 -1
- package/dist/src/item-navigator.d.ts +17 -11
- package/dist/src/item-navigator.js +29 -50
- package/dist/src/item-navigator.js.map +1 -1
- package/dist/src/no-theater-available.js.map +1 -1
- package/dist/test/ia-item-navigator.test.js +32 -23
- package/dist/test/ia-item-navigator.test.js.map +1 -1
- package/package.json +2 -2
- package/src/interfaces/menu-interfaces.ts +3 -2
- package/src/item-navigator.ts +44 -62
- package/src/no-theater-available.ts +2 -4
- package/test/ia-item-navigator.test.ts +42 -31
- package/demo/demo-book-manifest.json +0 -1163
- package/src/item-inspector/files-by-type/files-by-type-provider.ts +0 -43
- package/src/item-inspector/files-by-type/ia-files-by-type.ts +0 -100
- package/src/item-inspector/share-provider.ts +0 -51
- package/src/item-inspector/visual-mod-provider.ts +0 -65
- package/src/item-navigator-js.js +0 -372
@@ -3,8 +3,9 @@ import { html, fixture, expect } from '@open-wc/testing';
|
|
3
3
|
import Sinon from 'sinon';
|
4
4
|
|
5
5
|
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
6
|
-
import {
|
7
|
-
import {
|
6
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
7
|
+
import { BookNavigator } from '../src/interfaces/nav-controller-interface';
|
8
|
+
import { ItemNavigator, ItemType } from '../src/item-navigator';
|
8
9
|
import '../src/item-navigator';
|
9
10
|
|
10
11
|
import '../test/book-nav-stub';
|
@@ -27,8 +28,10 @@ describe('ItemNavigator', () => {
|
|
27
28
|
it('shows <book-navigator> if `this.itemType = "bookreader"`', async () => {
|
28
29
|
const el = await fixture<ItemNavigator>(
|
29
30
|
html`<ia-item-navigator
|
30
|
-
.itemType=${
|
31
|
+
.itemType=${ItemType.BOOK}
|
31
32
|
.item=${new ItemStub()}
|
33
|
+
.modal=${new ModalManager()}
|
34
|
+
.sharedObserver=${new SharedResizeObserver()}
|
32
35
|
></ia-item-navigator>`
|
33
36
|
);
|
34
37
|
|
@@ -39,7 +42,7 @@ describe('ItemNavigator', () => {
|
|
39
42
|
|
40
43
|
const bookNavigator = el.shadowRoot?.querySelector(
|
41
44
|
'book-navigator'
|
42
|
-
) as
|
45
|
+
) as BookNavigator;
|
43
46
|
await bookNavigator.updateComplete;
|
44
47
|
|
45
48
|
console.log('132234234324324324');
|
@@ -91,10 +94,10 @@ describe('ItemNavigator', () => {
|
|
91
94
|
await el.updateComplete;
|
92
95
|
const spy = Sinon.spy();
|
93
96
|
el.loadingStateUpdated = spy;
|
94
|
-
el.loaded =
|
97
|
+
el.loaded = null;
|
95
98
|
await el.updateComplete;
|
96
99
|
// check base properties
|
97
|
-
expect(el.loaded).to.equal(
|
100
|
+
expect(el.loaded).to.equal(null);
|
98
101
|
expect(el.item).to.be.undefined;
|
99
102
|
|
100
103
|
// hydrate item
|
@@ -108,50 +111,58 @@ describe('ItemNavigator', () => {
|
|
108
111
|
});
|
109
112
|
|
110
113
|
describe('`el.sharedObserver`', () => {
|
111
|
-
it('
|
114
|
+
it('uses one', async () => {
|
115
|
+
const sharedObserver = new SharedResizeObserver();
|
112
116
|
const el = await fixture<ItemNavigator>(
|
113
|
-
html`<ia-item-navigator
|
117
|
+
html`<ia-item-navigator
|
118
|
+
.sharedObserver=${sharedObserver}
|
119
|
+
></ia-item-navigator>`
|
114
120
|
);
|
115
|
-
await el.updateComplete;
|
116
|
-
expect(el.sharedObserver).to.not.be.null;
|
117
|
-
expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);
|
118
|
-
});
|
119
121
|
|
120
|
-
|
122
|
+
expect(el.sharedObserver).to.equal(sharedObserver);
|
123
|
+
});
|
124
|
+
it('freshly registers handler', async () => {
|
121
125
|
const sharedObserver = new SharedResizeObserver();
|
126
|
+
const addObserverSpy = Sinon.spy(sharedObserver, 'addObserver');
|
127
|
+
const removeObserverSpy = Sinon.spy(sharedObserver, 'removeObserver');
|
122
128
|
|
123
|
-
|
129
|
+
await fixture<ItemNavigator>(
|
124
130
|
html`<ia-item-navigator
|
125
131
|
.sharedObserver=${sharedObserver}
|
126
132
|
></ia-item-navigator>`
|
127
133
|
);
|
128
|
-
await el.updateComplete;
|
129
|
-
expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);
|
130
|
-
});
|
131
|
-
});
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
html`<ia-item-navigator></ia-item-navigator>`
|
137
|
-
);
|
138
|
-
await el.updateComplete;
|
139
|
-
expect(el.sharedObserver).to.not.be.null;
|
140
|
-
expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);
|
135
|
+
// always calls to remove first, for posterity
|
136
|
+
expect(removeObserverSpy.callCount).to.equal(1);
|
137
|
+
expect(addObserverSpy.callCount).to.equal(1);
|
141
138
|
});
|
142
|
-
|
143
|
-
it('can recieve one', async () => {
|
139
|
+
it('removes handler when component disconnects', async () => {
|
144
140
|
const sharedObserver = new SharedResizeObserver();
|
145
|
-
const
|
141
|
+
const removeObserverSpy = Sinon.spy(sharedObserver, 'removeObserver');
|
146
142
|
|
147
143
|
const el = await fixture<ItemNavigator>(
|
148
144
|
html`<ia-item-navigator
|
149
145
|
.sharedObserver=${sharedObserver}
|
150
146
|
></ia-item-navigator>`
|
151
147
|
);
|
148
|
+
|
149
|
+
// called during setup `setResizeObserver`
|
150
|
+
expect(removeObserverSpy.callCount).to.equal(1);
|
151
|
+
|
152
|
+
el.disconnectedCallback();
|
152
153
|
await el.updateComplete;
|
153
|
-
|
154
|
-
expect(
|
154
|
+
|
155
|
+
expect(removeObserverSpy.callCount).to.equal(2);
|
156
|
+
});
|
157
|
+
});
|
158
|
+
|
159
|
+
describe('`el.modal`', () => {
|
160
|
+
it('uses one', async () => {
|
161
|
+
const modal = new ModalManager();
|
162
|
+
const el = await fixture<ItemNavigator>(
|
163
|
+
html`<ia-item-navigator .modal=${modal}></ia-item-navigator>`
|
164
|
+
);
|
165
|
+
expect(el.modal).to.equal(modal);
|
155
166
|
});
|
156
167
|
});
|
157
168
|
|