@internetarchive/ia-item-navigator 1.0.4 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/ci.yml +4 -5
- package/.github/workflows/gh-pages-main.yml +39 -0
- package/.github/workflows/pr-preview.yml +38 -0
- package/demo/app-root.ts +13 -13
- package/dist/demo/app-root.d.ts +47 -47
- package/dist/demo/app-root.js +200 -199
- package/dist/demo/app-root.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/src/interfaces/custom-theater-interface.d.ts +20 -20
- package/dist/src/interfaces/custom-theater-interface.js +1 -1
- package/dist/src/interfaces/event-interfaces.d.ts +40 -40
- package/dist/src/interfaces/event-interfaces.js +1 -1
- package/dist/src/interfaces/menu-interfaces.d.ts +23 -22
- package/dist/src/interfaces/menu-interfaces.js +1 -1
- package/dist/src/interfaces/menu-interfaces.js.map +1 -1
- package/dist/src/item-navigator.d.ts +69 -69
- package/dist/src/item-navigator.js +259 -257
- package/dist/src/item-navigator.js.map +1 -1
- package/dist/src/loader.d.ts +9 -13
- package/dist/src/loader.js +35 -31
- package/dist/src/loader.js.map +1 -1
- package/dist/src/menu-slider/ia-menu-slider.d.ts +31 -30
- package/dist/src/menu-slider/ia-menu-slider.js +123 -124
- package/dist/src/menu-slider/ia-menu-slider.js.map +1 -1
- package/dist/src/menu-slider/menu-button.d.ts +19 -19
- package/dist/src/menu-slider/menu-button.js +75 -75
- package/dist/src/menu-slider/menu-button.js.map +1 -1
- package/dist/src/menu-slider/styles/menu-button.d.ts +2 -2
- package/dist/src/menu-slider/styles/menu-button.js +2 -2
- package/dist/src/menu-slider/styles/menu-slider.d.ts +2 -2
- package/dist/src/menu-slider/styles/menu-slider.js +5 -5
- package/dist/src/no-theater-available.d.ts +9 -9
- package/dist/src/no-theater-available.js +35 -35
- package/dist/src/no-theater-available.js.map +1 -1
- package/dist/test/ia-item-navigator.test.d.ts +1 -1
- package/dist/test/ia-item-navigator.test.js +296 -296
- package/dist/test/ia-item-navigator.test.js.map +1 -1
- package/dist/test/ia-stub.d.ts +22 -22
- package/dist/test/ia-stub.js +34 -34
- package/dist/test/no-theater-available.test.d.ts +1 -1
- package/dist/test/no-theater-available.test.js +22 -22
- package/dist/test/no-theater-available.test.js.map +1 -1
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.config.js +25 -0
- package/dist/vite.config.js.map +1 -0
- package/package.json +35 -21
- package/src/interfaces/menu-interfaces.ts +3 -1
- package/src/item-navigator.ts +9 -4
- package/src/loader.ts +5 -7
- package/src/menu-slider/ia-menu-slider.ts +17 -17
- package/src/menu-slider/menu-button.ts +3 -3
- package/src/no-theater-available.ts +1 -1
- package/test/ia-item-navigator.test.ts +24 -24
- package/test/iaux-item-navigator.test.txt +417 -0
- package/test/iaux-sharing-options.test.txt +84 -0
- package/test/no-theater-available.test.ts +2 -2
- package/tsconfig.json +2 -1
- package/vite.config.ts +25 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
2
|
+
import sinon from 'sinon';
|
3
|
+
import '../src/menus/iaux-sharing-options';
|
4
|
+
import type { IauxSharingOptions } from '../src/menus/iaux-sharing-options';
|
5
|
+
|
6
|
+
const identifier = 'goody';
|
7
|
+
const itemType = 'book';
|
8
|
+
const creator = 'Welsh, Charles';
|
9
|
+
const description =
|
10
|
+
'The history of Little Goody Two-Shoes : otherwise called Mrs. Margery Two-Shoes ... [1766 edition]';
|
11
|
+
|
12
|
+
const container = (optionalFileSubprefix = '') =>
|
13
|
+
html`<iaux-sharing-options
|
14
|
+
identifier="${identifier}"
|
15
|
+
type="${itemType}"
|
16
|
+
creator="${creator}"
|
17
|
+
description="${description}"
|
18
|
+
baseHost="archive.org"
|
19
|
+
fileSubPrefix="${optionalFileSubprefix}"
|
20
|
+
></iaux-sharing-options>`;
|
21
|
+
|
22
|
+
describe('<iaux-sharing-options>', () => {
|
23
|
+
afterEach(() => {
|
24
|
+
sinon.restore();
|
25
|
+
});
|
26
|
+
|
27
|
+
it('sets default properties', async () => {
|
28
|
+
const el = (await fixture(container())) as IauxSharingOptions;
|
29
|
+
|
30
|
+
expect(el.identifier).to.equal(identifier);
|
31
|
+
expect(el.type).to.equal(itemType);
|
32
|
+
expect(el.creator).to.equal(creator);
|
33
|
+
expect(el.description).to.equal(description);
|
34
|
+
});
|
35
|
+
|
36
|
+
it('renders buttons for each sharing method', async () => {
|
37
|
+
const el = (await fixture(container())) as IauxSharingOptions;
|
38
|
+
|
39
|
+
await el.updateComplete;
|
40
|
+
|
41
|
+
el.sharingOptions.forEach(option => {
|
42
|
+
const button =
|
43
|
+
el.shadowRoot && el.shadowRoot.querySelector(`a.${option.class}`);
|
44
|
+
expect(button).to.exist;
|
45
|
+
expect(button?.getAttribute('href')).to.equal(option.url);
|
46
|
+
});
|
47
|
+
});
|
48
|
+
|
49
|
+
it('toggles visibility of embed options', async () => {
|
50
|
+
const el = (await fixture(container())) as IauxSharingOptions;
|
51
|
+
|
52
|
+
el.toggleEmbedOptions(new Event('click'));
|
53
|
+
await el.updateComplete;
|
54
|
+
|
55
|
+
expect(el.embedOptionsVisible).to.equal(true);
|
56
|
+
});
|
57
|
+
|
58
|
+
it('does not show internal header by default', async () => {
|
59
|
+
const el = (await fixture(container())) as IauxSharingOptions;
|
60
|
+
expect(el.shadowRoot?.querySelector('header')).to.be.null;
|
61
|
+
});
|
62
|
+
|
63
|
+
it('does shows internal header when requested', async () => {
|
64
|
+
const el = (await fixture(container())) as IauxSharingOptions;
|
65
|
+
el.renderHeader = true;
|
66
|
+
await el.updateComplete;
|
67
|
+
expect(el.shadowRoot?.querySelector('header')).to.not.be.null;
|
68
|
+
});
|
69
|
+
|
70
|
+
it('sets file subprefix to end of share URLs if present', async () => {
|
71
|
+
const optionalFileSubprefix = 'foo- bar - 123-';
|
72
|
+
const el = (await fixture(
|
73
|
+
container(optionalFileSubprefix),
|
74
|
+
)) as IauxSharingOptions;
|
75
|
+
|
76
|
+
el.sharingOptions.forEach(option => {
|
77
|
+
if (option.name !== 'Tumblr') {
|
78
|
+
expect(option.url).to.contain(
|
79
|
+
encodeURIComponent(optionalFileSubprefix),
|
80
|
+
);
|
81
|
+
}
|
82
|
+
});
|
83
|
+
});
|
84
|
+
});
|
@@ -7,7 +7,7 @@ describe('IANoTheaterAvailable', () => {
|
|
7
7
|
const el = await fixture<IANoTheaterAvailable>(
|
8
8
|
html`<ia-no-theater-available
|
9
9
|
.identifier=${`foo`}
|
10
|
-
></ia-no-theater-available
|
10
|
+
></ia-no-theater-available>`,
|
11
11
|
);
|
12
12
|
let eventFired = false;
|
13
13
|
el.addEventListener('loadingStateUpdated', () => {
|
@@ -24,7 +24,7 @@ describe('IANoTheaterAvailable', () => {
|
|
24
24
|
const el = await fixture<IANoTheaterAvailable>(
|
25
25
|
html`<ia-no-theater-available
|
26
26
|
.identifier=${`foo`}
|
27
|
-
></ia-no-theater-available
|
27
|
+
></ia-no-theater-available>`,
|
28
28
|
);
|
29
29
|
expect(el.downloadUrl).to.equal('/download/foo');
|
30
30
|
expect(el?.shadowRoot?.querySelector('a')?.href).to.contain(el.downloadUrl);
|
package/tsconfig.json
CHANGED
package/vite.config.ts
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineConfig } from 'vite';
|
2
|
+
import { resolve } from 'path';
|
3
|
+
|
4
|
+
// https://vitejs.dev/config/
|
5
|
+
export default defineConfig({
|
6
|
+
base: './',
|
7
|
+
root: resolve(__dirname, './demo'),
|
8
|
+
build: {
|
9
|
+
/**
|
10
|
+
* This is the directory where the built files will be placed
|
11
|
+
* that we upload to GitHub Pages.
|
12
|
+
*/
|
13
|
+
outDir: '../ghpages/demo',
|
14
|
+
emptyOutDir: true,
|
15
|
+
manifest: true,
|
16
|
+
rollupOptions: {
|
17
|
+
input: {
|
18
|
+
main: resolve(__dirname, 'demo/index.html'),
|
19
|
+
},
|
20
|
+
output: {
|
21
|
+
entryFileNames: 'app-root.js',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
},
|
25
|
+
});
|