@internetarchive/ia-item-navigator 0.0.0-a10 → 0.0.0-a12
Sign up to get free protection for your applications and to get access to all the features.
- package/demo/app-root.ts +6 -4
- package/dist/demo/app-root.d.ts +0 -1
- package/dist/demo/app-root.js +1 -3
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/interfaces/nav-controller-interface.d.ts +9 -0
- package/dist/src/interfaces/nav-controller-interface.js.map +1 -1
- package/dist/src/item-inspector/item-inspector.d.ts +0 -47
- package/dist/src/item-inspector/item-inspector.js +253 -271
- package/dist/src/item-inspector/item-inspector.js.map +1 -1
- package/dist/src/item-navigator.d.ts +14 -7
- package/dist/src/item-navigator.js +60 -30
- package/dist/src/item-navigator.js.map +1 -1
- package/dist/src/no-theater-available.d.ts +9 -0
- package/dist/src/no-theater-available.js +79 -0
- package/dist/src/no-theater-available.js.map +1 -0
- package/dist/test/book-nav-stub.d.ts +17 -0
- package/dist/test/book-nav-stub.js +42 -0
- package/dist/test/book-nav-stub.js.map +1 -0
- package/dist/test/ia-item-navigator.test.d.ts +1 -0
- package/dist/test/ia-item-navigator.test.js +146 -114
- package/dist/test/ia-item-navigator.test.js.map +1 -1
- package/dist/test/ia-stub.d.ts +22 -0
- package/dist/test/ia-stub.js +34 -3
- package/dist/test/ia-stub.js.map +1 -1
- package/dist/test/no-theater-available.test.d.ts +1 -0
- package/dist/test/no-theater-available.test.js +27 -0
- package/dist/test/no-theater-available.test.js.map +1 -0
- package/package.json +3 -2
- package/src/interfaces/nav-controller-interface.ts +13 -0
- package/src/item-navigator.ts +69 -36
- package/src/no-theater-available.ts +87 -0
- package/test/book-nav-stub.ts +35 -0
- package/test/ia-item-navigator.test.ts +191 -143
- package/test/ia-stub.ts +78 -2
- package/test/no-theater-available.test.ts +32 -0
- package/src/item-inspector/item-inspector.ts +0 -296
@@ -1,94 +1,84 @@
|
|
1
1
|
/* eslint-disable camelcase */
|
2
|
-
/* eslint-disable import/no-duplicates */
|
3
2
|
import { html, fixture, expect } from '@open-wc/testing';
|
4
3
|
import Sinon from 'sinon';
|
5
|
-
|
6
|
-
import { SharedResizeObserver,
|
7
|
-
// SharedResizeObserverInterface
|
8
|
-
} from '@internetarchive/shared-resize-observer';
|
4
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
9
5
|
import '../src/item-navigator';
|
10
|
-
|
11
|
-
|
12
|
-
// constructor() {
|
13
|
-
// this.rawResponse = '';
|
14
|
-
// this.created = 1;
|
15
|
-
// this.d1 = 'hello';
|
16
|
-
// this.d2 = 'boop';
|
17
|
-
// this.dir = 'whee';
|
18
|
-
// this.files = [];
|
19
|
-
// this.files_count = 0;
|
20
|
-
// this.item_last_updated = 2020;
|
21
|
-
// this.item_size = 111;
|
22
|
-
// this.metadata = { identifier: 'foo' } as Metadata;
|
23
|
-
// this.server = 'foo-server';
|
24
|
-
// this.uniq = 2;
|
25
|
-
// this.workable_servers = ['abc'];
|
26
|
-
// }
|
27
|
-
// rawResponse: any;
|
28
|
-
// created: number;
|
29
|
-
// d1: string;
|
30
|
-
// d2: string;
|
31
|
-
// dir: string;
|
32
|
-
// files: File[];
|
33
|
-
// files_count: number;
|
34
|
-
// item_last_updated: number;
|
35
|
-
// item_size: number;
|
36
|
-
// metadata: Metadata;
|
37
|
-
// server: string;
|
38
|
-
// uniq: number;
|
39
|
-
// workable_servers: string[];
|
40
|
-
// speech_vs_music_asr?: SpeechMusicASREntry[] | undefined;
|
41
|
-
// reviews?: Review[] | undefined;
|
42
|
-
// };
|
6
|
+
import '../test/book-nav-stub';
|
7
|
+
import { ItemStub, menuProvider, shortcut } from '../test/ia-stub';
|
43
8
|
afterEach(() => {
|
44
9
|
Sinon.restore();
|
45
10
|
});
|
46
11
|
describe('ItemNavigator', () => {
|
47
|
-
describe('
|
48
|
-
it('shows
|
12
|
+
describe('Theaters', () => {
|
13
|
+
it('shows <ia-no-theater-available> by default', async () => {
|
49
14
|
var _a;
|
50
|
-
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
51
|
-
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ia-
|
15
|
+
const el = await fixture(html `<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`);
|
16
|
+
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ia-no-theater-available')).to.exist;
|
52
17
|
});
|
53
|
-
it('
|
18
|
+
it('shows <book-navigator> if `this.itemType = "bookreader"`', async () => {
|
54
19
|
var _a;
|
55
|
-
const el = await fixture(html `<ia-item-navigator
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
20
|
+
const el = await fixture(html `<ia-item-navigator
|
21
|
+
.itemType=${`bookreader`}
|
22
|
+
.item=${new ItemStub()}
|
23
|
+
></ia-item-navigator>`);
|
24
|
+
await el.updateComplete;
|
25
|
+
el.toggleMenu();
|
26
|
+
await el.updateComplete;
|
27
|
+
const bookNavigator = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('book-navigator');
|
28
|
+
await bookNavigator.updateComplete;
|
29
|
+
console.log('132234234324324324');
|
30
|
+
// TODO: add BookNavigator type & import via @internetarchive/bookreader
|
31
|
+
// For now, let's check that the BookNavigator element and its properties exist w/ stub
|
32
|
+
expect(bookNavigator).to.exist;
|
33
|
+
expect(bookNavigator === null || bookNavigator === void 0 ? void 0 : bookNavigator.modal).to.exist;
|
34
|
+
expect(bookNavigator === null || bookNavigator === void 0 ? void 0 : bookNavigator.baseHost).to.exist;
|
35
|
+
expect(bookNavigator === null || bookNavigator === void 0 ? void 0 : bookNavigator.book).to.exist;
|
36
|
+
expect(bookNavigator === null || bookNavigator === void 0 ? void 0 : bookNavigator.signedIn).to.be.null;
|
37
|
+
expect(bookNavigator === null || bookNavigator === void 0 ? void 0 : bookNavigator.sharedObserver).to.exist;
|
38
|
+
expect(bookNavigator === null || bookNavigator === void 0 ? void 0 : bookNavigator.sideMenuOpen).to.exist;
|
61
39
|
});
|
62
|
-
|
40
|
+
});
|
41
|
+
describe('`el.loaded`', () => {
|
42
|
+
it('toggles the spinning loader', async () => {
|
63
43
|
var _a;
|
64
44
|
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
65
|
-
el.loaded
|
66
|
-
|
45
|
+
expect(el.loaded).to.be.null; // initial load
|
46
|
+
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ia-itemnav-loader')).to.exist;
|
47
|
+
});
|
48
|
+
it('hides reader section if `!loaded`', async () => {
|
49
|
+
var _a, _b;
|
50
|
+
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
51
|
+
expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#reader')) === null || _b === void 0 ? void 0 : _b.getAttribute('class')).to.contain('hide');
|
52
|
+
});
|
53
|
+
it('shows reader when `loaded` ', async () => {
|
54
|
+
var _a, _b;
|
55
|
+
const el = await fixture(html `<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`);
|
67
56
|
const mainTheaterSection = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#reader');
|
68
57
|
expect(mainTheaterSection === null || mainTheaterSection === void 0 ? void 0 : mainTheaterSection.classList.contains('hide')).to.be.false;
|
69
58
|
expect(el.loaded).to.be.true;
|
70
59
|
// `loaded` property is reflected as DOM attribute
|
71
60
|
expect(el.hasAttribute('loaded')).to.equal(true);
|
61
|
+
expect((_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('ia-no-theater-available')).to.exist;
|
62
|
+
});
|
63
|
+
it('listens to `@loadingStateUpdated` to update `loaded`', async () => {
|
64
|
+
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
65
|
+
await el.updateComplete;
|
66
|
+
const spy = Sinon.spy();
|
67
|
+
el.loadingStateUpdated = spy;
|
68
|
+
el.loaded = false;
|
69
|
+
await el.updateComplete;
|
70
|
+
// check base properties
|
71
|
+
expect(el.loaded).to.equal(false);
|
72
|
+
expect(el.item).to.be.undefined;
|
73
|
+
// hydrate item
|
74
|
+
el.item = new ItemStub();
|
75
|
+
await el.updateComplete;
|
76
|
+
// spy fires
|
77
|
+
expect(spy.called).to.equal(true);
|
78
|
+
expect(spy.callCount).to.equal(1);
|
72
79
|
});
|
73
|
-
// it('listens to event `loadingStateUpdated` to signal load', async () => {
|
74
|
-
// const item = new ItemStub() as MetadataResponse;
|
75
|
-
// const el = await fixture<ItemNavigator>(
|
76
|
-
// html`<ia-item-navigator .item=${item}></ia-item-navigator>`
|
77
|
-
// );
|
78
|
-
// // const loadSpy = Sinon.spy();
|
79
|
-
// // el.loadingStateUpdated = loadSpy;
|
80
|
-
// await el.updateComplete;
|
81
|
-
// expect(el?.item).to.not.be.undefined;
|
82
|
-
// const mainTheaterSection = el.shadowRoot?.querySelector('#reader');
|
83
|
-
// const contentController = mainTheaterSection?.querySelector('ia-item-inspector');
|
84
|
-
// expect(contentController).to.equal(32324);
|
85
|
-
// // const loadingEvent = new CustomEvent('loadingStateUpdated', { detail: { loaded: true }}) as IntLoadingStateUpdatedEvent;
|
86
|
-
// // contentController?.emitLoadingStatusUpdate(true);
|
87
|
-
// // await contentController?.updateComplete;
|
88
|
-
// // await el.updateComplete;
|
89
|
-
// });
|
90
80
|
});
|
91
|
-
describe('
|
81
|
+
describe('`el.sharedObserver`', () => {
|
92
82
|
it('can create one', async () => {
|
93
83
|
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
94
84
|
await el.updateComplete;
|
@@ -104,7 +94,7 @@ describe('ItemNavigator', () => {
|
|
104
94
|
expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);
|
105
95
|
});
|
106
96
|
});
|
107
|
-
describe('
|
97
|
+
describe('`el.modal`', () => {
|
108
98
|
it('can create one', async () => {
|
109
99
|
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
110
100
|
await el.updateComplete;
|
@@ -122,48 +112,90 @@ describe('ItemNavigator', () => {
|
|
122
112
|
expect(observerSpy.called).to.equal(true);
|
123
113
|
});
|
124
114
|
});
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
115
|
+
describe('full browser window immersion "fullscreen"', () => {
|
116
|
+
it('creates reflected attribute `viewportinfullscreen`', async () => {
|
117
|
+
/** to help with external styling adjustmnents */
|
118
|
+
const el = await fixture(html `<ia-item-navigator></ia-item-navigator>`);
|
119
|
+
expect(el.getAttribute('viewportinfullscreen')).to.be.null;
|
120
|
+
el.viewportInFullscreen = true;
|
121
|
+
await el.updateComplete;
|
122
|
+
expect(el.getAttribute('viewportinfullscreen')).to.exist;
|
123
|
+
});
|
124
|
+
});
|
125
|
+
/* Side menu & shortcuts tests */
|
126
|
+
describe('el.menuOpened', () => {
|
127
|
+
it('toggles side menu open', async () => {
|
128
|
+
var _a, _b, _c;
|
129
|
+
const el = await fixture(html `<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`);
|
130
|
+
el.menuContents = [menuProvider];
|
131
|
+
await el.updateComplete;
|
132
|
+
const nav = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('nav');
|
133
|
+
expect(nav === null || nav === void 0 ? void 0 : nav.querySelector('#menu')).to.exist;
|
134
|
+
// side menu starts closed
|
135
|
+
expect(el.menuOpened).to.be.false;
|
136
|
+
expect((_b = nav === null || nav === void 0 ? void 0 : nav.querySelector('#menu')) === null || _b === void 0 ? void 0 : _b.getAttribute('class')).to.contain('hidden');
|
137
|
+
// let's open menu
|
138
|
+
el.toggleMenu();
|
139
|
+
await el.updateComplete;
|
140
|
+
expect(el.menuOpened).to.be.true;
|
141
|
+
expect((_c = nav === null || nav === void 0 ? void 0 : nav.querySelector('#menu')) === null || _c === void 0 ? void 0 : _c.getAttribute('class')).to.not.contain('hidden');
|
142
|
+
});
|
143
|
+
it('opens menu shortcut with `@manageSideMenuEvents`', async () => {
|
144
|
+
var _a;
|
145
|
+
const el = await fixture(html `<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`);
|
146
|
+
const detail = {
|
147
|
+
menuId: 'fullscreen',
|
148
|
+
action: 'open',
|
149
|
+
};
|
150
|
+
el.menuContents = [menuProvider];
|
151
|
+
await el.updateComplete;
|
152
|
+
const frame = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#frame');
|
153
|
+
// default menu open behavior is to side menu open, not overlay
|
154
|
+
expect(frame === null || frame === void 0 ? void 0 : frame.getAttribute('class')).to.contain('shift');
|
155
|
+
expect(el.menuOpened).to.be.false;
|
156
|
+
expect(el.openMenu).to.be.empty;
|
157
|
+
expect(frame === null || frame === void 0 ? void 0 : frame.getAttribute('class')).to.not.contain('open');
|
158
|
+
const event = new CustomEvent('updateSideMenu', {
|
159
|
+
detail,
|
160
|
+
});
|
161
|
+
el.manageSideMenuEvents(event);
|
162
|
+
await el.updateComplete;
|
163
|
+
expect(el.shouldRenderMenu).to.be.true;
|
164
|
+
expect(el.menuOpened).to.be.true;
|
165
|
+
expect(el.openMenu).to.equal(detail.menuId);
|
166
|
+
expect(frame === null || frame === void 0 ? void 0 : frame.getAttribute('class')).to.contain('open');
|
167
|
+
});
|
168
|
+
});
|
169
|
+
describe('el.menuContents', () => {
|
170
|
+
it('draws side menu when populated', async () => {
|
171
|
+
var _a;
|
172
|
+
const el = await fixture(html `<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`);
|
173
|
+
el.menuContents = [menuProvider];
|
174
|
+
await el.updateComplete;
|
175
|
+
expect(el.menuContents.length).to.exist;
|
176
|
+
expect(el.shouldRenderMenu).to.be.true;
|
177
|
+
const nav = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('nav');
|
178
|
+
expect(nav).to.exist;
|
179
|
+
const menuSlider = nav === null || nav === void 0 ? void 0 : nav.querySelector('ia-menu-slider');
|
180
|
+
expect(menuSlider).to.exist;
|
181
|
+
expect(menuSlider === null || menuSlider === void 0 ? void 0 : menuSlider.getAttribute('manuallyhandleclose')).to.exist;
|
182
|
+
expect(menuSlider === null || menuSlider === void 0 ? void 0 : menuSlider.getAttribute('open')).to.exist;
|
183
|
+
});
|
184
|
+
});
|
185
|
+
describe('`el.menuShortcuts`', () => {
|
186
|
+
it('displays shortcut & toggle side menu button', async () => {
|
187
|
+
var _a, _b;
|
188
|
+
const el = await fixture(html `<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`);
|
189
|
+
el.menuContents = [menuProvider];
|
190
|
+
el.menuShortcuts = [shortcut];
|
191
|
+
await el.updateComplete;
|
192
|
+
const nav = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('nav');
|
193
|
+
expect(el.menuShortcuts.length).to.exist;
|
194
|
+
expect(nav).to.exist;
|
195
|
+
expect(nav === null || nav === void 0 ? void 0 : nav.querySelector('.shortcuts')).to.exist;
|
196
|
+
expect((_b = nav === null || nav === void 0 ? void 0 : nav.querySelector('.shortcuts')) === null || _b === void 0 ? void 0 : _b.querySelector('i.fullscreen-test')).to.exist;
|
197
|
+
expect(nav === null || nav === void 0 ? void 0 : nav.querySelector('.toggle-menu')).to.exist;
|
198
|
+
});
|
199
|
+
});
|
140
200
|
});
|
141
|
-
// describe('YourWebComponent', () => {
|
142
|
-
// it('has a default title "Hey there" and counter 5', async () => {
|
143
|
-
// const el = await fixture<YourWebComponent>(
|
144
|
-
// html`<your-webcomponent></your-webcomponent>`
|
145
|
-
// );
|
146
|
-
// expect(el.title).to.equal('Hey there');
|
147
|
-
// expect(el.counter).to.equal(5);
|
148
|
-
// });
|
149
|
-
// it('increases the counter on button click', async () => {
|
150
|
-
// const el = await fixture<YourWebComponent>(
|
151
|
-
// html`<your-webcomponent></your-webcomponent>`
|
152
|
-
// );
|
153
|
-
// el.shadowRoot!.querySelector('button')!.click();
|
154
|
-
// expect(el.counter).to.equal(6);
|
155
|
-
// });
|
156
|
-
// it('can override the title via attribute', async () => {
|
157
|
-
// const el = await fixture<YourWebComponent>(
|
158
|
-
// html`<your-webcomponent title="attribute title"></your-webcomponent>`
|
159
|
-
// );
|
160
|
-
// expect(el.title).to.equal('attribute title');
|
161
|
-
// });
|
162
|
-
// it('passes the a11y audit', async () => {
|
163
|
-
// const el = await fixture<YourWebComponent>(
|
164
|
-
// html`<your-webcomponent></your-webcomponent>`
|
165
|
-
// );
|
166
|
-
// await expect(el).shadowDom.to.be.accessible();
|
167
|
-
// });
|
168
|
-
// });
|
169
201
|
//# sourceMappingURL=ia-item-navigator.test.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ia-item-navigator.test.js","sourceRoot":"","sources":["../../test/ia-item-navigator.test.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,yCAAyC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,mHAAmH;AACnH,OAAO,EACL,oBAAoB;AACpB,gCAAgC;EACjC,MAAM,yCAAyC,CAAC;AAIjD,OAAO,uBAAuB,CAAC;AAC/B,0EAA0E;AAE1E,+CAA+C;AAC/C,oBAAoB;AACpB,6BAA6B;AAC7B,wBAAwB;AACxB,yBAAyB;AACzB,wBAAwB;AACxB,yBAAyB;AACzB,uBAAuB;AACvB,4BAA4B;AAC5B,qCAAqC;AACrC,4BAA4B;AAC5B,yDAAyD;AACzD,kCAAkC;AAClC,qBAAqB;AACrB,uCAAuC;AACvC,MAAM;AAEN,sBAAsB;AAEtB,qBAAqB;AAErB,gBAAgB;AAEhB,gBAAgB;AAEhB,iBAAiB;AAEjB,mBAAmB;AAEnB,yBAAyB;AAEzB,+BAA+B;AAE/B,uBAAuB;AAEvB,wBAAwB;AAExB,oBAAoB;AAEpB,kBAAkB;AAElB,gCAAgC;AAEhC,6DAA6D;AAE7D,oCAAoC;AACpC,KAAK;AAEL,SAAS,CAAC,GAAG,EAAE;IAC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AAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,iEAAiE;IACjE,oEAAoE;IACpE,wDAAwD;IACxD,QAAQ;IACR,MAAM;IAEN,8CAA8C;IAC9C,MAAM;IAEN,qCAAqC;IACrC,MAAM;IAEN,8CAA8C;IAC9C,kDAAkD;IAClD,sDAAsD;IACtD,SAAS;IAET,qDAAqD;IACrD,QAAQ;AACV,CAAC,CAAC,CAAC;AAEH,uCAAuC;AACvC,sEAAsE;AACtE,kDAAkD;AAClD,sDAAsD;AACtD,SAAS;AAET,8CAA8C;AAC9C,sCAAsC;AACtC,QAAQ;AAER,8DAA8D;AAC9D,kDAAkD;AAClD,sDAAsD;AACtD,SAAS;AACT,uDAAuD;AAEvD,sCAAsC;AACtC,QAAQ;AAER,6DAA6D;AAC7D,kDAAkD;AAClD,8EAA8E;AAC9E,SAAS;AAET,oDAAoD;AACpD,QAAQ;AAER,8CAA8C;AAC9C,kDAAkD;AAClD,sDAAsD;AACtD,SAAS;AAET,qDAAqD;AACrD,QAAQ;AACR,MAAM","sourcesContent":["/* eslint-disable camelcase */\n/* eslint-disable import/no-duplicates */\nimport { html, fixture, expect } from '@open-wc/testing';\nimport Sinon from 'sinon';\n// import { MetadataResponse, Metadata, File, Review, SpeechMusicASREntry } from '@internetarchive/search-service';\nimport {\n SharedResizeObserver,\n // SharedResizeObserverInterface\n} from '@internetarchive/shared-resize-observer';\n\n// import { IntLoadingStateUpdatedEvent } from '../src/interfaces/event-interfaces';\nimport { ItemNavigator } from '../src/item-navigator';\nimport '../src/item-navigator';\n// import { IaItemInspector } from '../src/item-inspector/item-inspector';\n\n// class ItemStub implements MetadataResponse {\n// constructor() {\n// this.rawResponse = '';\n// this.created = 1;\n// this.d1 = 'hello';\n// this.d2 = 'boop';\n// this.dir = 'whee';\n// this.files = [];\n// this.files_count = 0;\n// this.item_last_updated = 2020;\n// this.item_size = 111;\n// this.metadata = { identifier: 'foo' } as Metadata;\n// this.server = 'foo-server';\n// this.uniq = 2;\n// this.workable_servers = ['abc'];\n// }\n\n// rawResponse: any;\n\n// created: number;\n\n// d1: string;\n\n// d2: string;\n\n// dir: string;\n\n// files: File[];\n\n// files_count: number;\n\n// item_last_updated: number;\n\n// item_size: number;\n\n// metadata: Metadata;\n\n// server: string;\n\n// uniq: number;\n\n// workable_servers: string[];\n\n// speech_vs_music_asr?: SpeechMusicASREntry[] | undefined;\n\n// reviews?: Review[] | undefined;\n// };\n\nafterEach(() => {\n Sinon.restore();\n});\n\ndescribe('ItemNavigator', () => {\n describe('Loading Behavior', () => {\n it('shows the spinning loader', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n expect(el.shadowRoot?.querySelector('ia-itemnav-loader')).to.be.exist;\n });\n it('hides reader section if not `loaded`', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n const mainTheaterSection = el.shadowRoot?.querySelector('#reader');\n expect(mainTheaterSection).to.be.exist;\n expect(mainTheaterSection?.classList.contains('hide')).to.be.true;\n expect(el.loaded).to.be.false;\n expect(el.hasAttribute('loaded')).to.equal(false);\n });\n it('shows reader once `loaded`', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n el.loaded = true;\n await el.updateComplete;\n\n const mainTheaterSection = el.shadowRoot?.querySelector('#reader');\n expect(mainTheaterSection?.classList.contains('hide')).to.be.false;\n expect(el.loaded).to.be.true;\n // `loaded` property is reflected as DOM attribute\n expect(el.hasAttribute('loaded')).to.equal(true);\n });\n\n // it('listens to event `loadingStateUpdated` to signal load', async () => {\n // const item = new ItemStub() as MetadataResponse;\n // const el = await fixture<ItemNavigator>(\n // html`<ia-item-navigator .item=${item}></ia-item-navigator>`\n // );\n // // const loadSpy = Sinon.spy();\n // // el.loadingStateUpdated = loadSpy;\n // await el.updateComplete;\n\n // expect(el?.item).to.not.be.undefined;\n\n // const mainTheaterSection = el.shadowRoot?.querySelector('#reader');\n\n // const contentController = mainTheaterSection?.querySelector('ia-item-inspector');\n\n // expect(contentController).to.equal(32324);\n\n // // const loadingEvent = new CustomEvent('loadingStateUpdated', { detail: { loaded: true }}) as IntLoadingStateUpdatedEvent;\n // // contentController?.emitLoadingStatusUpdate(true);\n\n // // await contentController?.updateComplete;\n // // await el.updateComplete;\n\n // });\n });\n\n describe('It uses a shared ResizeObserver', () => {\n it('can create one', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.not.be.null;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n });\n\n it('can recieve one', async () => {\n const sharedObserver = new SharedResizeObserver();\n\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator\n .sharedObserver=${sharedObserver}\n ></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n });\n });\n\n describe('It uses a shared modal component', () => {\n it('can create one', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.not.be.null;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n });\n\n it('can recieve one', async () => {\n const sharedObserver = new SharedResizeObserver();\n const observerSpy = Sinon.stub(sharedObserver, 'addObserver');\n\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator\n .sharedObserver=${sharedObserver}\n ></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n expect(observerSpy.called).to.equal(true);\n });\n });\n\n // describe('full browser window immersion \"fullscreen\"', () => {\n // it('creates reflected attribute `viewportinfullscreen`', () =>{\n // /** to help with external styling adjustmnents */\n // });\n // });\n\n // describe('Loads side menu contents', () =>{\n // });\n\n // describe('Menu Shortcuts', () => {\n // });\n\n // it('passes the a11y audit', async () => {\n // const el = await fixture<YourWebComponent>(\n // html`<your-webcomponent></your-webcomponent>`\n // );\n\n // await expect(el).shadowDom.to.be.accessible();\n // });\n});\n\n// describe('YourWebComponent', () => {\n// it('has a default title \"Hey there\" and counter 5', async () => {\n// const el = await fixture<YourWebComponent>(\n// html`<your-webcomponent></your-webcomponent>`\n// );\n\n// expect(el.title).to.equal('Hey there');\n// expect(el.counter).to.equal(5);\n// });\n\n// it('increases the counter on button click', async () => {\n// const el = await fixture<YourWebComponent>(\n// html`<your-webcomponent></your-webcomponent>`\n// );\n// el.shadowRoot!.querySelector('button')!.click();\n\n// expect(el.counter).to.equal(6);\n// });\n\n// it('can override the title via attribute', async () => {\n// const el = await fixture<YourWebComponent>(\n// html`<your-webcomponent title=\"attribute title\"></your-webcomponent>`\n// );\n\n// expect(el.title).to.equal('attribute title');\n// });\n\n// it('passes the a11y audit', async () => {\n// const el = await fixture<YourWebComponent>(\n// html`<your-webcomponent></your-webcomponent>`\n// );\n\n// await expect(el).shadowDom.to.be.accessible();\n// });\n// });\n"]}
|
1
|
+
{"version":3,"file":"ia-item-navigator.test.js","sourceRoot":"","sources":["../../test/ia-item-navigator.test.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAG/E,OAAO,uBAAuB,CAAC;AAE/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGnE,SAAS,CAAC,GAAG,EAAE;IACb,KAAK,CAAC,OAAO,EAAE,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EA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AAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;;YAC3D,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,4BAA4B,IAAI,QAAQ,EAAE,uBAAuB,CACtE,CAAC;YAEF,EAAE,CAAC,YAAY,GAAG,CAAC,YAAY,CAAC,CAAC;YACjC,EAAE,CAAC,aAAa,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC9B,MAAM,EAAE,CAAC,cAAc,CAAC;YAExB,MAAM,GAAG,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,KAAK,CAAC,CAAC;YAEhD,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YACzC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YACrB,MAAM,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YAClD,MAAM,CACJ,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,CAAC,YAAY,CAAC,0CAAE,aAAa,CAAC,mBAAmB,CAAC,CACrE,CAAC,EAAE,CAAC,KAAK,CAAC;YACX,MAAM,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable camelcase */\nimport { html, fixture, expect } from '@open-wc/testing';\nimport Sinon from 'sinon';\n\nimport { SharedResizeObserver } from '@internetarchive/shared-resize-observer';\nimport { IntNavController } from '../src/interfaces/nav-controller-interface';\nimport { ItemNavigator } from '../src/item-navigator';\nimport '../src/item-navigator';\n\nimport '../test/book-nav-stub';\nimport { ItemStub, menuProvider, shortcut } from '../test/ia-stub';\nimport { IntManageSideMenuEvent } from '../src/interfaces/event-interfaces';\n\nafterEach(() => {\n Sinon.restore();\n});\n\ndescribe('ItemNavigator', () => {\n describe('Theaters', () => {\n it('shows <ia-no-theater-available> by default', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`\n );\n expect(el.shadowRoot?.querySelector('ia-no-theater-available')).to.exist;\n });\n\n it('shows <book-navigator> if `this.itemType = \"bookreader\"`', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator\n .itemType=${`bookreader`}\n .item=${new ItemStub()}\n ></ia-item-navigator>`\n );\n\n await el.updateComplete;\n\n el.toggleMenu();\n await el.updateComplete;\n\n const bookNavigator = el.shadowRoot?.querySelector(\n 'book-navigator'\n ) as IntNavController;\n await bookNavigator.updateComplete;\n\n console.log('132234234324324324');\n // TODO: add BookNavigator type & import via @internetarchive/bookreader\n // For now, let's check that the BookNavigator element and its properties exist w/ stub\n expect(bookNavigator).to.exist;\n expect(bookNavigator?.modal).to.exist;\n expect(bookNavigator?.baseHost).to.exist;\n expect(bookNavigator?.book).to.exist;\n expect(bookNavigator?.signedIn).to.be.null;\n expect(bookNavigator?.sharedObserver).to.exist;\n expect(bookNavigator?.sideMenuOpen).to.exist;\n });\n });\n describe('`el.loaded`', () => {\n it('toggles the spinning loader', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n expect(el.loaded).to.be.null; // initial load\n expect(el.shadowRoot?.querySelector('ia-itemnav-loader')).to.exist;\n });\n it('hides reader section if `!loaded`', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n\n expect(\n el.shadowRoot?.querySelector('#reader')?.getAttribute('class')\n ).to.contain('hide');\n });\n it('shows reader when `loaded` ', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`\n );\n\n const mainTheaterSection = el.shadowRoot?.querySelector('#reader');\n expect(mainTheaterSection?.classList.contains('hide')).to.be.false;\n expect(el.loaded).to.be.true;\n // `loaded` property is reflected as DOM attribute\n expect(el.hasAttribute('loaded')).to.equal(true);\n expect(el.shadowRoot?.querySelector('ia-no-theater-available')).to.exist;\n });\n it('listens to `@loadingStateUpdated` to update `loaded`', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n\n await el.updateComplete;\n const spy = Sinon.spy();\n el.loadingStateUpdated = spy;\n el.loaded = false;\n await el.updateComplete;\n // check base properties\n expect(el.loaded).to.equal(false);\n expect(el.item).to.be.undefined;\n\n // hydrate item\n el.item = new ItemStub();\n await el.updateComplete;\n\n // spy fires\n expect(spy.called).to.equal(true);\n expect(spy.callCount).to.equal(1);\n });\n });\n\n describe('`el.sharedObserver`', () => {\n it('can create one', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.not.be.null;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n });\n\n it('can recieve one', async () => {\n const sharedObserver = new SharedResizeObserver();\n\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator\n .sharedObserver=${sharedObserver}\n ></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n });\n });\n\n describe('`el.modal`', () => {\n it('can create one', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.not.be.null;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n });\n\n it('can recieve one', async () => {\n const sharedObserver = new SharedResizeObserver();\n const observerSpy = Sinon.stub(sharedObserver, 'addObserver');\n\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator\n .sharedObserver=${sharedObserver}\n ></ia-item-navigator>`\n );\n await el.updateComplete;\n expect(el.sharedObserver).to.be.instanceOf(SharedResizeObserver);\n expect(observerSpy.called).to.equal(true);\n });\n });\n\n describe('full browser window immersion \"fullscreen\"', () => {\n it('creates reflected attribute `viewportinfullscreen`', async () => {\n /** to help with external styling adjustmnents */\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator></ia-item-navigator>`\n );\n expect(el.getAttribute('viewportinfullscreen')).to.be.null;\n\n el.viewportInFullscreen = true;\n await el.updateComplete;\n\n expect(el.getAttribute('viewportinfullscreen')).to.exist;\n });\n });\n\n /* Side menu & shortcuts tests */\n describe('el.menuOpened', () => {\n it('toggles side menu open', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`\n );\n\n el.menuContents = [menuProvider];\n await el.updateComplete;\n\n const nav = el.shadowRoot?.querySelector('nav');\n\n expect(nav?.querySelector('#menu')).to.exist;\n // side menu starts closed\n expect(el.menuOpened).to.be.false;\n expect(nav?.querySelector('#menu')?.getAttribute('class')).to.contain(\n 'hidden'\n );\n\n // let's open menu\n el.toggleMenu();\n await el.updateComplete;\n\n expect(el.menuOpened).to.be.true;\n expect(nav?.querySelector('#menu')?.getAttribute('class')).to.not.contain(\n 'hidden'\n );\n });\n\n it('opens menu shortcut with `@manageSideMenuEvents`', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`\n );\n const detail = {\n menuId: 'fullscreen',\n action: 'open',\n };\n\n el.menuContents = [menuProvider];\n await el.updateComplete;\n const frame = el.shadowRoot?.querySelector('#frame');\n // default menu open behavior is to side menu open, not overlay\n expect(frame?.getAttribute('class')).to.contain('shift');\n\n expect(el.menuOpened).to.be.false;\n expect(el.openMenu).to.be.empty;\n expect(frame?.getAttribute('class')).to.not.contain('open');\n\n const event = new CustomEvent('updateSideMenu', {\n detail,\n }) as IntManageSideMenuEvent;\n el.manageSideMenuEvents(event);\n await el.updateComplete;\n\n expect(el.shouldRenderMenu).to.be.true;\n expect(el.menuOpened).to.be.true;\n expect(el.openMenu).to.equal(detail.menuId);\n\n expect(frame?.getAttribute('class')).to.contain('open');\n });\n });\n\n describe('el.menuContents', () => {\n it('draws side menu when populated', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`\n );\n\n el.menuContents = [menuProvider];\n await el.updateComplete;\n expect(el.menuContents.length).to.exist;\n expect(el.shouldRenderMenu).to.be.true;\n\n const nav = el.shadowRoot?.querySelector('nav');\n expect(nav).to.exist;\n\n const menuSlider = nav?.querySelector('ia-menu-slider');\n expect(menuSlider).to.exist;\n expect(menuSlider?.getAttribute('manuallyhandleclose')).to.exist;\n expect(menuSlider?.getAttribute('open')).to.exist;\n });\n });\n\n describe('`el.menuShortcuts`', () => {\n it('displays shortcut & toggle side menu button', async () => {\n const el = await fixture<ItemNavigator>(\n html`<ia-item-navigator .item=${new ItemStub()}></ia-item-navigator>`\n );\n\n el.menuContents = [menuProvider];\n el.menuShortcuts = [shortcut];\n await el.updateComplete;\n\n const nav = el.shadowRoot?.querySelector('nav');\n\n expect(el.menuShortcuts.length).to.exist;\n expect(nav).to.exist;\n expect(nav?.querySelector('.shortcuts')).to.exist;\n expect(\n nav?.querySelector('.shortcuts')?.querySelector('i.fullscreen-test')\n ).to.exist;\n expect(nav?.querySelector('.toggle-menu')).to.exist;\n });\n });\n});\n"]}
|
package/dist/test/ia-stub.d.ts
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
import { MetadataResponse, Metadata, File, Review, SpeechMusicASREntry } from '@internetarchive/search-service';
|
2
|
+
import { IntMenuShortcut, IntMenuProvider } from '../src/interfaces/menu-interfaces';
|
3
|
+
export declare class ItemStub implements MetadataResponse {
|
4
|
+
constructor();
|
5
|
+
rawResponse: any;
|
6
|
+
created: number;
|
7
|
+
d1: string;
|
8
|
+
d2: string;
|
9
|
+
dir: string;
|
10
|
+
files: File[];
|
11
|
+
files_count: number;
|
12
|
+
item_last_updated: number;
|
13
|
+
item_size: number;
|
14
|
+
metadata: Metadata;
|
15
|
+
server: string;
|
16
|
+
uniq: number;
|
17
|
+
workable_servers: string[];
|
18
|
+
speech_vs_music_asr?: SpeechMusicASREntry[] | undefined;
|
19
|
+
reviews?: Review[] | undefined;
|
20
|
+
}
|
21
|
+
export declare const shortcut: IntMenuShortcut;
|
22
|
+
export declare const menuProvider: IntMenuProvider;
|
package/dist/test/ia-stub.js
CHANGED
@@ -1,4 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import { html } from 'lit-html';
|
2
|
+
export class ItemStub {
|
3
|
+
constructor() {
|
4
|
+
this.rawResponse = '';
|
5
|
+
this.created = 1;
|
6
|
+
this.d1 = 'hello';
|
7
|
+
this.d2 = 'boop';
|
8
|
+
this.dir = 'whee';
|
9
|
+
this.files = [];
|
10
|
+
this.files_count = 0;
|
11
|
+
this.item_last_updated = 2020;
|
12
|
+
this.item_size = 111;
|
13
|
+
this.metadata = { identifier: 'foo' };
|
14
|
+
this.server = 'foo-server';
|
15
|
+
this.uniq = 2;
|
16
|
+
this.workable_servers = ['abc'];
|
17
|
+
}
|
18
|
+
}
|
19
|
+
export const shortcut = {
|
20
|
+
id: 'fullscreen',
|
21
|
+
icon: html `<i class="fas fullscreen-test"></i>`,
|
22
|
+
};
|
23
|
+
export const menuProvider = {
|
24
|
+
...shortcut,
|
25
|
+
label: 'foo',
|
26
|
+
menuDetails: html `<div>foo</div>`,
|
27
|
+
selected: true,
|
28
|
+
followable: false,
|
29
|
+
href: 'https://archive.foo',
|
30
|
+
item: new ItemStub(),
|
31
|
+
baseHost: 'https://archive.foo',
|
32
|
+
subPrefix: 'bar',
|
33
|
+
updated: () => { },
|
34
|
+
};
|
4
35
|
//# sourceMappingURL=ia-stub.js.map
|
package/dist/test/ia-stub.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ia-stub.js","sourceRoot":"","sources":["../../test/ia-stub.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"ia-stub.js","sourceRoot":"","sources":["../../test/ia-stub.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAMhC,MAAM,OAAO,QAAQ;IACnB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;QAClB,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,EAAE,UAAU,EAAE,KAAK,EAAc,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,gBAAgB,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CA+BF;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,IAAI,CAAA,qCAAqC;CAC7B,CAAC;AAErB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,QAAQ;IACX,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,IAAI,CAAA,gBAAgB;IACjC,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,IAAI,QAAQ,EAAE;IACpB,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CACC,CAAC","sourcesContent":["/* eslint-disable camelcase */\nimport {\n MetadataResponse,\n Metadata,\n File,\n Review,\n SpeechMusicASREntry,\n} from '@internetarchive/search-service';\nimport { html } from 'lit-html';\nimport {\n IntMenuShortcut,\n IntMenuProvider,\n} from '../src/interfaces/menu-interfaces';\n\nexport class ItemStub implements MetadataResponse {\n constructor() {\n this.rawResponse = '';\n this.created = 1;\n this.d1 = 'hello';\n this.d2 = 'boop';\n this.dir = 'whee';\n this.files = [];\n this.files_count = 0;\n this.item_last_updated = 2020;\n this.item_size = 111;\n this.metadata = { identifier: 'foo' } as Metadata;\n this.server = 'foo-server';\n this.uniq = 2;\n this.workable_servers = ['abc'];\n }\n\n rawResponse: any;\n\n created: number;\n\n d1: string;\n\n d2: string;\n\n dir: string;\n\n files: File[];\n\n files_count: number;\n\n item_last_updated: number;\n\n item_size: number;\n\n metadata: Metadata;\n\n server: string;\n\n uniq: number;\n\n workable_servers: string[];\n\n speech_vs_music_asr?: SpeechMusicASREntry[] | undefined;\n\n reviews?: Review[] | undefined;\n}\n\nexport const shortcut = {\n id: 'fullscreen',\n icon: html`<i class=\"fas fullscreen-test\"></i>`,\n} as IntMenuShortcut;\n\nexport const menuProvider = {\n ...shortcut,\n label: 'foo',\n menuDetails: html`<div>foo</div>`,\n selected: true,\n followable: false,\n href: 'https://archive.foo',\n item: new ItemStub(),\n baseHost: 'https://archive.foo',\n subPrefix: 'bar',\n updated: () => {},\n} as IntMenuProvider;\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
import '../src/no-theater-available';
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
2
|
+
import '../src/no-theater-available';
|
3
|
+
describe('IANoTheaterAvailable', () => {
|
4
|
+
it('Fires `loadingStateUpdated` on identifier change', async () => {
|
5
|
+
const el = await fixture(html `<ia-no-theater-available
|
6
|
+
.identifier=${`foo`}
|
7
|
+
></ia-no-theater-available>`);
|
8
|
+
let eventFired = false;
|
9
|
+
el.addEventListener('loadingStateUpdated', () => {
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
11
|
+
eventFired = true;
|
12
|
+
});
|
13
|
+
expect(eventFired).to.be.false;
|
14
|
+
el.identifier = 'bar';
|
15
|
+
await el.updateComplete;
|
16
|
+
expect(eventFired).to.be.true;
|
17
|
+
});
|
18
|
+
it('Has link to item download page', async () => {
|
19
|
+
var _a, _b;
|
20
|
+
const el = await fixture(html `<ia-no-theater-available
|
21
|
+
.identifier=${`foo`}
|
22
|
+
></ia-no-theater-available>`);
|
23
|
+
expect(el.downloadUrl).to.equal('/download/foo');
|
24
|
+
expect((_b = (_a = el === null || el === void 0 ? void 0 : el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('a')) === null || _b === void 0 ? void 0 : _b.href).to.contain(el.downloadUrl);
|
25
|
+
});
|
26
|
+
});
|
27
|
+
//# sourceMappingURL=no-theater-available.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"no-theater-available.test.js","sourceRoot":"","sources":["../../test/no-theater-available.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,6BAA6B,CAAC;AAErC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA;sBACY,KAAK;kCACO,CAC7B,CAAC;QACF,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,EAAE,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,GAAG,EAAE;YAC9C,6DAA6D;YAC7D,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAE/B,EAAE,CAAC,UAAU,GAAG,KAAK,CAAC;QACtB,MAAM,EAAE,CAAC,cAAc,CAAC;QACxB,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;;QAC9C,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA;sBACY,KAAK;kCACO,CAC7B,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACjD,MAAM,CAAC,MAAA,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,UAAU,0CAAE,aAAa,CAAC,GAAG,CAAC,0CAAE,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, fixture, expect } from '@open-wc/testing';\nimport { IANoTheaterAvailable } from '../src/no-theater-available';\nimport '../src/no-theater-available';\n\ndescribe('IANoTheaterAvailable', () => {\n it('Fires `loadingStateUpdated` on identifier change', async () => {\n const el = await fixture<IANoTheaterAvailable>(\n html`<ia-no-theater-available\n .identifier=${`foo`}\n ></ia-no-theater-available>`\n );\n let eventFired = false;\n el.addEventListener('loadingStateUpdated', () => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n eventFired = true;\n });\n expect(eventFired).to.be.false;\n\n el.identifier = 'bar';\n await el.updateComplete;\n expect(eventFired).to.be.true;\n });\n it('Has link to item download page', async () => {\n const el = await fixture<IANoTheaterAvailable>(\n html`<ia-no-theater-available\n .identifier=${`foo`}\n ></ia-no-theater-available>`\n );\n expect(el.downloadUrl).to.equal('/download/foo');\n expect(el?.shadowRoot?.querySelector('a')?.href).to.contain(el.downloadUrl);\n });\n});\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@internetarchive/ia-item-navigator",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-a12",
|
4
4
|
"description": "Internet Archive's Item Navigator, visually eplore an item's contents.",
|
5
5
|
"author": "Internet Archive",
|
6
6
|
"license": "AGPL-3.0-only",
|
@@ -78,7 +78,8 @@
|
|
78
78
|
"js": "never",
|
79
79
|
"ts": "never"
|
80
80
|
}
|
81
|
-
]
|
81
|
+
],
|
82
|
+
"import/no-duplicates": "off"
|
82
83
|
}
|
83
84
|
},
|
84
85
|
"prettier": {
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { LitElement } from 'lit-element';
|
2
2
|
import { MetadataResponse } from '@internetarchive/search-service';
|
3
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
4
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
3
5
|
import { IntMenuShortcut } from './menu-interfaces';
|
4
6
|
|
5
7
|
export interface IntNavController extends LitElement {
|
@@ -9,10 +11,21 @@ export interface IntNavController extends LitElement {
|
|
9
11
|
menuShortcuts: IntMenuShortcut[];
|
10
12
|
sideMenuOpen: boolean;
|
11
13
|
|
14
|
+
signedIn: boolean;
|
15
|
+
|
16
|
+
sharedObserver: SharedResizeObserver;
|
17
|
+
modal: ModalManager;
|
18
|
+
|
12
19
|
emitLoadingStatusUpdate: (loaded: boolean) => void;
|
13
20
|
|
14
21
|
addMenuShortcut: (menuId: string) => void;
|
15
22
|
removeMenuShortcut: (menuId: string) => void;
|
16
23
|
sortMenuShortcuts: () => void;
|
17
24
|
emitMenuShortcutsUpdated: () => void;
|
25
|
+
|
26
|
+
book: MetadataResponse;
|
27
|
+
}
|
28
|
+
|
29
|
+
export interface BookNavigator extends IntNavController {
|
30
|
+
book: MetadataResponse;
|
18
31
|
}
|