@internetarchive/ia-topnav 1.3.6 → 1.3.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +16 -16
- package/LICENSE +661 -661
- package/README.md +147 -147
- package/index.d.ts +109 -109
- package/index.js +3 -3
- package/package.json +61 -61
- package/src/assets/img/hamburger.js +38 -38
- package/src/assets/img/ia-icon.js +33 -33
- package/src/assets/img/icon-audio.js +23 -23
- package/src/assets/img/icon-close.js +16 -16
- package/src/assets/img/icon-donate-unpadded.js +16 -16
- package/src/assets/img/icon-donate.js +15 -15
- package/src/assets/img/icon-ellipses.js +15 -15
- package/src/assets/img/icon-ia-logo.js +22 -22
- package/src/assets/img/icon-images.js +15 -15
- package/src/assets/img/icon-search.js +15 -15
- package/src/assets/img/icon-software.js +15 -15
- package/src/assets/img/icon-texts.js +15 -15
- package/src/assets/img/icon-upload-unpadded.js +14 -14
- package/src/assets/img/icon-upload.js +15 -15
- package/src/assets/img/icon-user.js +15 -15
- package/src/assets/img/icon-video.js +15 -15
- package/src/assets/img/icon-web.js +15 -15
- package/src/assets/img/icon.js +18 -18
- package/src/assets/img/icons.js +33 -33
- package/src/assets/img/wordmark-stacked.js +13 -13
- package/src/data/menus.js +646 -646
- package/src/desktop-subnav.js +45 -45
- package/src/dropdown-menu.js +110 -109
- package/src/ia-topnav.js +324 -314
- package/src/lib/formatUrl.js +1 -1
- package/src/lib/keyboard-navigation.js +128 -0
- package/src/lib/location-handler.js +5 -5
- package/src/lib/query-handler.js +7 -7
- package/src/lib/toSentenceCase.js +8 -8
- package/src/login-button.js +79 -79
- package/src/media-button.js +113 -113
- package/src/media-menu.js +154 -133
- package/src/media-slider.js +118 -104
- package/src/media-subnav.js +112 -112
- package/src/more-slider.js +33 -33
- package/src/nav-search.js +111 -117
- package/src/primary-nav.js +258 -224
- package/src/save-page-form.js +59 -59
- package/src/search-menu.js +145 -115
- package/src/signed-out-dropdown.js +10 -10
- package/src/styles/base.js +48 -48
- package/src/styles/desktop-subnav.js +37 -37
- package/src/styles/dropdown-menu.js +168 -166
- package/src/styles/ia-topnav.js +87 -87
- package/src/styles/login-button.js +82 -79
- package/src/styles/media-button.js +156 -156
- package/src/styles/media-menu.js +66 -70
- package/src/styles/media-slider.js +81 -81
- package/src/styles/media-subnav.js +156 -156
- package/src/styles/more-slider.js +15 -15
- package/src/styles/nav-search.js +136 -136
- package/src/styles/primary-nav.js +311 -300
- package/src/styles/save-page-form.js +54 -54
- package/src/styles/search-menu.js +105 -99
- package/src/styles/signed-out-dropdown.js +31 -31
- package/src/styles/user-menu.js +31 -31
- package/src/styles/wayback-search.js +48 -48
- package/src/styles/wayback-slider.js +30 -30
- package/src/tracked-element.js +29 -27
- package/src/user-menu.js +56 -42
- package/src/wayback-search.js +18 -18
- package/src/wayback-slider.js +87 -87
- package/test/assets/img/hamburger.test.js +15 -15
- package/test/assets/img/user.test.js +15 -15
- package/test/data/menus.test.js +19 -19
- package/test/dropdown-menu.test.js +25 -25
- package/test/ia-icon.test.js +13 -13
- package/test/ia-topnav.test.js +273 -273
- package/test/login-button.test.js +15 -15
- package/test/media-button.test.js +19 -19
- package/test/media-menu.test.js +40 -40
- package/test/media-slider.test.js +57 -57
- package/test/more-slider.test.js +13 -13
- package/test/nav-search.test.js +61 -61
- package/test/primary-nav.test.js +82 -82
- package/test/save-page-form.test.js +35 -35
- package/test/search-menu.test.js +49 -49
- package/test/user-menu.test.js +33 -33
- package/test/wayback-slider.test.js +80 -80
package/test/media-menu.test.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
-
|
|
3
|
-
import '../src/media-menu';
|
|
4
|
-
|
|
5
|
-
const component = html`<media-menu></media-menu>`;
|
|
6
|
-
|
|
7
|
-
describe('<media-menu>', () => {
|
|
8
|
-
it('sets default properties', async () => {
|
|
9
|
-
const mediaMenu = await fixture(component);
|
|
10
|
-
|
|
11
|
-
expect(mediaMenu.openMenu).to.equal('');
|
|
12
|
-
expect(mediaMenu.selectedMenuOption).to.equal('');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('renders menu icon as selected when selectedMenuOption matches', async () => {
|
|
16
|
-
const mediaMenu = await fixture(component);
|
|
17
|
-
const mediaType = 'texts';
|
|
18
|
-
|
|
19
|
-
mediaMenu.selectedMenuOption = mediaType;
|
|
20
|
-
await mediaMenu.updateComplete;
|
|
21
|
-
|
|
22
|
-
const textsButton = mediaMenu
|
|
23
|
-
.shadowRoot
|
|
24
|
-
.querySelector(`[data-mediatype=${mediaType}`)
|
|
25
|
-
.shadowRoot
|
|
26
|
-
.querySelector('.selected');
|
|
27
|
-
|
|
28
|
-
expect(textsButton).to.not.be.null;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('renders with closed class if done animating', async () => {
|
|
32
|
-
const mediaMenu = await fixture(component);
|
|
33
|
-
|
|
34
|
-
mediaMenu.mediaMenuAnimate = true;
|
|
35
|
-
await mediaMenu.updateComplete;
|
|
36
|
-
|
|
37
|
-
expect(mediaMenu.shadowRoot.querySelector('.media-menu-container').classList.contains('closed'))
|
|
38
|
-
.to.be.true;
|
|
39
|
-
});
|
|
40
|
-
});
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
+
|
|
3
|
+
import '../src/media-menu';
|
|
4
|
+
|
|
5
|
+
const component = html`<media-menu></media-menu>`;
|
|
6
|
+
|
|
7
|
+
describe('<media-menu>', () => {
|
|
8
|
+
it('sets default properties', async () => {
|
|
9
|
+
const mediaMenu = await fixture(component);
|
|
10
|
+
|
|
11
|
+
expect(mediaMenu.openMenu).to.equal('');
|
|
12
|
+
expect(mediaMenu.selectedMenuOption).to.equal('');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders menu icon as selected when selectedMenuOption matches', async () => {
|
|
16
|
+
const mediaMenu = await fixture(component);
|
|
17
|
+
const mediaType = 'texts';
|
|
18
|
+
|
|
19
|
+
mediaMenu.selectedMenuOption = mediaType;
|
|
20
|
+
await mediaMenu.updateComplete;
|
|
21
|
+
|
|
22
|
+
const textsButton = mediaMenu
|
|
23
|
+
.shadowRoot
|
|
24
|
+
.querySelector(`[data-mediatype=${mediaType}`)
|
|
25
|
+
.shadowRoot
|
|
26
|
+
.querySelector('.selected');
|
|
27
|
+
|
|
28
|
+
expect(textsButton).to.not.be.null;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders with closed class if done animating', async () => {
|
|
32
|
+
const mediaMenu = await fixture(component);
|
|
33
|
+
|
|
34
|
+
mediaMenu.mediaMenuAnimate = true;
|
|
35
|
+
await mediaMenu.updateComplete;
|
|
36
|
+
|
|
37
|
+
expect(mediaMenu.shadowRoot.querySelector('.media-menu-container').classList.contains('closed'))
|
|
38
|
+
.to.be.true;
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
-
|
|
3
|
-
import '../src/media-slider';
|
|
4
|
-
import { buildTopNavMenus } from '../../src/data/menus.js';
|
|
5
|
-
|
|
6
|
-
const menus = buildTopNavMenus();
|
|
7
|
-
|
|
8
|
-
const component = (mediaSliderOpen, selectedMenuOption) => (
|
|
9
|
-
html`<media-slider
|
|
10
|
-
?mediaSliderOpen="${mediaSliderOpen}"
|
|
11
|
-
selectedMenuOption="${selectedMenuOption}"
|
|
12
|
-
.menus=${menus}></media-slider>`
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
describe('<media-slider>', () => {
|
|
16
|
-
it('sets default properties', async () => {
|
|
17
|
-
const mediaSlider = await fixture(component(false, ''));
|
|
18
|
-
|
|
19
|
-
expect(mediaSlider.mediaSliderOpen).to.be.false;
|
|
20
|
-
expect(mediaSlider.selectedMenuOption).to.equal('');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('renders a media subnav when texts selected', async () => {
|
|
24
|
-
const mediaSlider = await fixture(component(false, 'texts'));
|
|
25
|
-
const menuHeading = mediaSlider.shadowRoot.querySelector('media-subnav[menu=texts]').shadowRoot.querySelector('h3');
|
|
26
|
-
|
|
27
|
-
expect(menuHeading.innerText).to.equal(menus.texts.heading);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('renders a media subnav when audio selected', async () => {
|
|
31
|
-
const mediaSlider = await fixture(component(false, 'audio'));
|
|
32
|
-
const menuHeading = mediaSlider.shadowRoot.querySelector('media-subnav[menu=audio]').shadowRoot.querySelector('h3');
|
|
33
|
-
|
|
34
|
-
expect(menuHeading.innerText).to.equal(menus.audio.heading);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('renders a media subnav when video selected', async () => {
|
|
38
|
-
const mediaSlider = await fixture(component(false, 'video'));
|
|
39
|
-
const menuHeading = mediaSlider.shadowRoot.querySelector('media-subnav[menu=video]').shadowRoot.querySelector('h3');
|
|
40
|
-
|
|
41
|
-
expect(menuHeading.innerText).to.equal(menus.video.heading);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('renders the Wayback component when web menu selected', async () => {
|
|
45
|
-
const mediaSlider = await fixture(component(false, 'web'));
|
|
46
|
-
const waybackSearch = mediaSlider.shadowRoot.querySelector('media-subnav[menu=web]').shadowRoot.querySelector('wayback-search');
|
|
47
|
-
|
|
48
|
-
expect(waybackSearch).to.not.be.undefined;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('renders the more links component when more menu selected', async () => {
|
|
52
|
-
const mediaSlider = await fixture(component(false, 'more'));
|
|
53
|
-
const moreSlider = mediaSlider.shadowRoot.querySelector('media-subnav[menu=more]').shadowRoot.querySelector('more-slider');
|
|
54
|
-
|
|
55
|
-
expect(moreSlider).to.not.be.undefined;
|
|
56
|
-
});
|
|
57
|
-
});
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
+
|
|
3
|
+
import '../src/media-slider';
|
|
4
|
+
import { buildTopNavMenus } from '../../src/data/menus.js';
|
|
5
|
+
|
|
6
|
+
const menus = buildTopNavMenus();
|
|
7
|
+
|
|
8
|
+
const component = (mediaSliderOpen, selectedMenuOption) => (
|
|
9
|
+
html`<media-slider
|
|
10
|
+
?mediaSliderOpen="${mediaSliderOpen}"
|
|
11
|
+
selectedMenuOption="${selectedMenuOption}"
|
|
12
|
+
.menus=${menus}></media-slider>`
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
describe('<media-slider>', () => {
|
|
16
|
+
it('sets default properties', async () => {
|
|
17
|
+
const mediaSlider = await fixture(component(false, ''));
|
|
18
|
+
|
|
19
|
+
expect(mediaSlider.mediaSliderOpen).to.be.false;
|
|
20
|
+
expect(mediaSlider.selectedMenuOption).to.equal('');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders a media subnav when texts selected', async () => {
|
|
24
|
+
const mediaSlider = await fixture(component(false, 'texts'));
|
|
25
|
+
const menuHeading = mediaSlider.shadowRoot.querySelector('media-subnav[menu=texts]').shadowRoot.querySelector('h3');
|
|
26
|
+
|
|
27
|
+
expect(menuHeading.innerText).to.equal(menus.texts.heading);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders a media subnav when audio selected', async () => {
|
|
31
|
+
const mediaSlider = await fixture(component(false, 'audio'));
|
|
32
|
+
const menuHeading = mediaSlider.shadowRoot.querySelector('media-subnav[menu=audio]').shadowRoot.querySelector('h3');
|
|
33
|
+
|
|
34
|
+
expect(menuHeading.innerText).to.equal(menus.audio.heading);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders a media subnav when video selected', async () => {
|
|
38
|
+
const mediaSlider = await fixture(component(false, 'video'));
|
|
39
|
+
const menuHeading = mediaSlider.shadowRoot.querySelector('media-subnav[menu=video]').shadowRoot.querySelector('h3');
|
|
40
|
+
|
|
41
|
+
expect(menuHeading.innerText).to.equal(menus.video.heading);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders the Wayback component when web menu selected', async () => {
|
|
45
|
+
const mediaSlider = await fixture(component(false, 'web'));
|
|
46
|
+
const waybackSearch = mediaSlider.shadowRoot.querySelector('media-subnav[menu=web]').shadowRoot.querySelector('wayback-search');
|
|
47
|
+
|
|
48
|
+
expect(waybackSearch).to.not.be.undefined;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('renders the more links component when more menu selected', async () => {
|
|
52
|
+
const mediaSlider = await fixture(component(false, 'more'));
|
|
53
|
+
const moreSlider = mediaSlider.shadowRoot.querySelector('media-subnav[menu=more]').shadowRoot.querySelector('more-slider');
|
|
54
|
+
|
|
55
|
+
expect(moreSlider).to.not.be.undefined;
|
|
56
|
+
});
|
|
57
|
+
});
|
package/test/more-slider.test.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
-
import '../src/more-slider';
|
|
3
|
-
import { buildTopNavMenus } from '../../src/data/menus.js';
|
|
4
|
-
|
|
5
|
-
describe('<more-slider>', () => {
|
|
6
|
-
it('renders links with relative hrefs using baseHost', async () => {
|
|
7
|
-
const menus = buildTopNavMenus();
|
|
8
|
-
const baseHost = 'archive.org';
|
|
9
|
-
const el = await fixture(html`<more-slider .baseHost=${baseHost} .config=${{}} .menuItems=${menus.more}>`);
|
|
10
|
-
|
|
11
|
-
expect(el.shadowRoot.querySelector('a').getAttribute('href')).to.contain(baseHost);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
+
import '../src/more-slider';
|
|
3
|
+
import { buildTopNavMenus } from '../../src/data/menus.js';
|
|
4
|
+
|
|
5
|
+
describe('<more-slider>', () => {
|
|
6
|
+
it('renders links with relative hrefs using baseHost', async () => {
|
|
7
|
+
const menus = buildTopNavMenus();
|
|
8
|
+
const baseHost = 'archive.org';
|
|
9
|
+
const el = await fixture(html`<more-slider .baseHost=${baseHost} .config=${{}} .menuItems=${menus.more}>`);
|
|
10
|
+
|
|
11
|
+
expect(el.shadowRoot.querySelector('a').getAttribute('href')).to.contain(baseHost);
|
|
12
|
+
});
|
|
13
|
+
});
|
package/test/nav-search.test.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
-
import sinon from 'sinon';
|
|
3
|
-
|
|
4
|
-
import '../src/nav-search';
|
|
5
|
-
|
|
6
|
-
const component = html`<nav-search></nav-search>`;
|
|
7
|
-
|
|
8
|
-
describe('<nav-search>', () => {
|
|
9
|
-
it('defaults to closed', async () => {
|
|
10
|
-
const el = await fixture(component);
|
|
11
|
-
|
|
12
|
-
expect(el.open).to.be.false;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('does not allow search form to submit if query empty', async () => {
|
|
16
|
-
const el = await fixture(component);
|
|
17
|
-
|
|
18
|
-
const result = el.search({
|
|
19
|
-
preventDefault: () => {}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
expect(result).to.be.false;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('redirects to the TV details page when search inside is TV', async () => {
|
|
26
|
-
const query = 'bananas';
|
|
27
|
-
const submitEvent = {
|
|
28
|
-
type: 'submit',
|
|
29
|
-
preventDefault: () => {}
|
|
30
|
-
};
|
|
31
|
-
const locationHandler = sinon.fake();
|
|
32
|
-
const el = await fixture(html`<nav-search .locationHandler=${locationHandler}></nav-search>`);
|
|
33
|
-
|
|
34
|
-
el.searchIn = 'TV';
|
|
35
|
-
|
|
36
|
-
await el.updateComplete;
|
|
37
|
-
|
|
38
|
-
el.shadowRoot.querySelector('[name=query]').value = query;
|
|
39
|
-
el.search(submitEvent);
|
|
40
|
-
|
|
41
|
-
expect(locationHandler.callCount).to.equal(1);
|
|
42
|
-
expect(locationHandler.firstArg).to.contain(`/details/tv?q=${query}`);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('prefills the search query when present in config', async () => {
|
|
46
|
-
const el = await fixture(html`<nav-search searchQuery='bananas'></nav-search>`);
|
|
47
|
-
|
|
48
|
-
expect(el.shadowRoot.querySelector('[name="query"]').value).to.equal('bananas');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('conditionally renders `sin` input based on `searchIn` truthiness', async () => {
|
|
52
|
-
const el = await fixture(component);
|
|
53
|
-
|
|
54
|
-
expect(el.shadowRoot.querySelector('[name="sin"]')).to.be.null;
|
|
55
|
-
|
|
56
|
-
el.searchIn = 'TV';
|
|
57
|
-
await el.updateComplete;
|
|
58
|
-
|
|
59
|
-
expect(el.shadowRoot.querySelector('[name="sin"]')).not.to.be.null;
|
|
60
|
-
});
|
|
61
|
-
});
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
|
|
4
|
+
import '../src/nav-search';
|
|
5
|
+
|
|
6
|
+
const component = html`<nav-search></nav-search>`;
|
|
7
|
+
|
|
8
|
+
describe('<nav-search>', () => {
|
|
9
|
+
it('defaults to closed', async () => {
|
|
10
|
+
const el = await fixture(component);
|
|
11
|
+
|
|
12
|
+
expect(el.open).to.be.false;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('does not allow search form to submit if query empty', async () => {
|
|
16
|
+
const el = await fixture(component);
|
|
17
|
+
|
|
18
|
+
const result = el.search({
|
|
19
|
+
preventDefault: () => {}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(result).to.be.false;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('redirects to the TV details page when search inside is TV', async () => {
|
|
26
|
+
const query = 'bananas';
|
|
27
|
+
const submitEvent = {
|
|
28
|
+
type: 'submit',
|
|
29
|
+
preventDefault: () => {}
|
|
30
|
+
};
|
|
31
|
+
const locationHandler = sinon.fake();
|
|
32
|
+
const el = await fixture(html`<nav-search .locationHandler=${locationHandler}></nav-search>`);
|
|
33
|
+
|
|
34
|
+
el.searchIn = 'TV';
|
|
35
|
+
|
|
36
|
+
await el.updateComplete;
|
|
37
|
+
|
|
38
|
+
el.shadowRoot.querySelector('[name=query]').value = query;
|
|
39
|
+
el.search(submitEvent);
|
|
40
|
+
|
|
41
|
+
expect(locationHandler.callCount).to.equal(1);
|
|
42
|
+
expect(locationHandler.firstArg).to.contain(`/details/tv?q=${query}`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('prefills the search query when present in config', async () => {
|
|
46
|
+
const el = await fixture(html`<nav-search searchQuery='bananas'></nav-search>`);
|
|
47
|
+
|
|
48
|
+
expect(el.shadowRoot.querySelector('[name="query"]').value).to.equal('bananas');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('conditionally renders `sin` input based on `searchIn` truthiness', async () => {
|
|
52
|
+
const el = await fixture(component);
|
|
53
|
+
|
|
54
|
+
expect(el.shadowRoot.querySelector('[name="sin"]')).to.be.null;
|
|
55
|
+
|
|
56
|
+
el.searchIn = 'TV';
|
|
57
|
+
await el.updateComplete;
|
|
58
|
+
|
|
59
|
+
expect(el.shadowRoot.querySelector('[name="sin"]')).not.to.be.null;
|
|
60
|
+
});
|
|
61
|
+
});
|
package/test/primary-nav.test.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
html, fixture, expect, fixtureCleanup, elementUpdated
|
|
3
|
-
} from '@open-wc/testing';
|
|
4
|
-
|
|
5
|
-
import '../src/primary-nav';
|
|
6
|
-
|
|
7
|
-
const component = ({
|
|
8
|
-
baseHost, username, screenName, hideSearch, config = {}, secondIdentitySlotMode
|
|
9
|
-
}) => (
|
|
10
|
-
html`
|
|
11
|
-
<primary-nav
|
|
12
|
-
.baseHost=${baseHost}
|
|
13
|
-
.username=${username}
|
|
14
|
-
.screenName=${screenName}
|
|
15
|
-
?hideSearch=${hideSearch}
|
|
16
|
-
.config=${config}
|
|
17
|
-
.secondIdentitySlotMode=${secondIdentitySlotMode}
|
|
18
|
-
></primary-nav>`
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
fixtureCleanup();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('<primary-nav>', () => {
|
|
26
|
-
it('renders the login link when no username present', async () => {
|
|
27
|
-
const el = await fixture(component({
|
|
28
|
-
baseHost: 'archive.org',
|
|
29
|
-
username: '',
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
expect(el.shadowRoot.querySelector('login-button')).to.not.be.undefined;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('does not render search menu toggle and search form if hideSearch true', async () => {
|
|
36
|
-
const el = await fixture(component({
|
|
37
|
-
baseHost: 'archive.org',
|
|
38
|
-
username: 'shaneriley',
|
|
39
|
-
screenName: 'shaneriley',
|
|
40
|
-
hideSearch: true,
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
expect(el.shadowRoot.querySelector('.search-trigger')).to.equal(null);
|
|
44
|
-
expect(el.shadowRoot.querySelector('nav-search')).to.equal(null);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('truncates a long screenname', async () => {
|
|
48
|
-
const el = await fixture(component({
|
|
49
|
-
baseHost: 'archive.org',
|
|
50
|
-
username: 'boop',
|
|
51
|
-
screenName: 'somesuperlongscreenname'
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
const usernameSpan = el.shadowRoot.querySelector('.username');
|
|
55
|
-
|
|
56
|
-
expect(usernameSpan.innerText).to.equal('somesuper…');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('opens a slot with `secondIdentitySlotMode`', async () => {
|
|
60
|
-
const el = await fixture(component({
|
|
61
|
-
baseHost: 'archive.org',
|
|
62
|
-
username: 'boop',
|
|
63
|
-
screenName: 'somesuperlongscreenname',
|
|
64
|
-
secondIdentitySlotMode: 'allow'
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
const brandingBlock = el.shadowRoot.querySelector('div.branding');
|
|
68
|
-
expect(brandingBlock.getAttribute('class')).to.contain('branding second-logo');
|
|
69
|
-
|
|
70
|
-
const slot = brandingBlock.querySelector('slot');
|
|
71
|
-
expect(slot).to.exist;
|
|
72
|
-
expect(slot.getAttribute('name')).to.equal('opt-sec-logo');
|
|
73
|
-
|
|
74
|
-
el.secondIdentitySlotMode = '';
|
|
75
|
-
await elementUpdated(el);
|
|
76
|
-
const noSlotBrandingBlock = el.shadowRoot.querySelector('div.branding');
|
|
77
|
-
expect(noSlotBrandingBlock.getAttribute('class')).to.contain('branding');
|
|
78
|
-
|
|
79
|
-
const noSlot = noSlotBrandingBlock.querySelector('slot');
|
|
80
|
-
expect(noSlot).to.not.exist;
|
|
81
|
-
});
|
|
82
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
html, fixture, expect, fixtureCleanup, elementUpdated
|
|
3
|
+
} from '@open-wc/testing';
|
|
4
|
+
|
|
5
|
+
import '../src/primary-nav';
|
|
6
|
+
|
|
7
|
+
const component = ({
|
|
8
|
+
baseHost, username, screenName, hideSearch, config = {}, secondIdentitySlotMode
|
|
9
|
+
}) => (
|
|
10
|
+
html`
|
|
11
|
+
<primary-nav
|
|
12
|
+
.baseHost=${baseHost}
|
|
13
|
+
.username=${username}
|
|
14
|
+
.screenName=${screenName}
|
|
15
|
+
?hideSearch=${hideSearch}
|
|
16
|
+
.config=${config}
|
|
17
|
+
.secondIdentitySlotMode=${secondIdentitySlotMode}
|
|
18
|
+
></primary-nav>`
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fixtureCleanup();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('<primary-nav>', () => {
|
|
26
|
+
it('renders the login link when no username present', async () => {
|
|
27
|
+
const el = await fixture(component({
|
|
28
|
+
baseHost: 'archive.org',
|
|
29
|
+
username: '',
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
expect(el.shadowRoot.querySelector('login-button')).to.not.be.undefined;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('does not render search menu toggle and search form if hideSearch true', async () => {
|
|
36
|
+
const el = await fixture(component({
|
|
37
|
+
baseHost: 'archive.org',
|
|
38
|
+
username: 'shaneriley',
|
|
39
|
+
screenName: 'shaneriley',
|
|
40
|
+
hideSearch: true,
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
expect(el.shadowRoot.querySelector('.search-trigger')).to.equal(null);
|
|
44
|
+
expect(el.shadowRoot.querySelector('nav-search')).to.equal(null);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('truncates a long screenname', async () => {
|
|
48
|
+
const el = await fixture(component({
|
|
49
|
+
baseHost: 'archive.org',
|
|
50
|
+
username: 'boop',
|
|
51
|
+
screenName: 'somesuperlongscreenname'
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
const usernameSpan = el.shadowRoot.querySelector('.username');
|
|
55
|
+
|
|
56
|
+
expect(usernameSpan.innerText).to.equal('somesuper…');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('opens a slot with `secondIdentitySlotMode`', async () => {
|
|
60
|
+
const el = await fixture(component({
|
|
61
|
+
baseHost: 'archive.org',
|
|
62
|
+
username: 'boop',
|
|
63
|
+
screenName: 'somesuperlongscreenname',
|
|
64
|
+
secondIdentitySlotMode: 'allow'
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
const brandingBlock = el.shadowRoot.querySelector('div.branding');
|
|
68
|
+
expect(brandingBlock.getAttribute('class')).to.contain('branding second-logo');
|
|
69
|
+
|
|
70
|
+
const slot = brandingBlock.querySelector('slot');
|
|
71
|
+
expect(slot).to.exist;
|
|
72
|
+
expect(slot.getAttribute('name')).to.equal('opt-sec-logo');
|
|
73
|
+
|
|
74
|
+
el.secondIdentitySlotMode = '';
|
|
75
|
+
await elementUpdated(el);
|
|
76
|
+
const noSlotBrandingBlock = el.shadowRoot.querySelector('div.branding');
|
|
77
|
+
expect(noSlotBrandingBlock.getAttribute('class')).to.contain('branding');
|
|
78
|
+
|
|
79
|
+
const noSlot = noSlotBrandingBlock.querySelector('slot');
|
|
80
|
+
expect(noSlot).to.not.exist;
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
-
|
|
3
|
-
import '../src/save-page-form';
|
|
4
|
-
|
|
5
|
-
const component = html`<save-page-form></save-page-form>`;
|
|
6
|
-
|
|
7
|
-
describe('<save-page-form>', () => {
|
|
8
|
-
it('checks validity of URL value and shows an error when invalid', async () => {
|
|
9
|
-
const el = await fixture(component);
|
|
10
|
-
const urlInput = el.shadowRoot.querySelector('[name="url_preload"]');
|
|
11
|
-
const errorMessage = el.shadowRoot.querySelector('.error');
|
|
12
|
-
const submitEvent = {
|
|
13
|
-
type: 'submit',
|
|
14
|
-
target: el.shadowRoot.querySelector('form'),
|
|
15
|
-
preventDefault: () => {}
|
|
16
|
-
};
|
|
17
|
-
submitEvent.currentTarget = submitEvent.target;
|
|
18
|
-
|
|
19
|
-
urlInput.value = 'archive';
|
|
20
|
-
el.validateURL(submitEvent);
|
|
21
|
-
|
|
22
|
-
await el.updateComplete;
|
|
23
|
-
|
|
24
|
-
expect(el.inputValid).to.be.false;
|
|
25
|
-
expect(errorMessage.getAttribute('class')).to.contain('visible');
|
|
26
|
-
|
|
27
|
-
urlInput.value += '.org';
|
|
28
|
-
el.validateURL(submitEvent);
|
|
29
|
-
|
|
30
|
-
await el.updateComplete;
|
|
31
|
-
|
|
32
|
-
expect(el.inputValid).to.be.true;
|
|
33
|
-
expect(errorMessage.getAttribute('class')).not.to.contain('visible');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
2
|
+
|
|
3
|
+
import '../src/save-page-form';
|
|
4
|
+
|
|
5
|
+
const component = html`<save-page-form></save-page-form>`;
|
|
6
|
+
|
|
7
|
+
describe('<save-page-form>', () => {
|
|
8
|
+
it('checks validity of URL value and shows an error when invalid', async () => {
|
|
9
|
+
const el = await fixture(component);
|
|
10
|
+
const urlInput = el.shadowRoot.querySelector('[name="url_preload"]');
|
|
11
|
+
const errorMessage = el.shadowRoot.querySelector('.error');
|
|
12
|
+
const submitEvent = {
|
|
13
|
+
type: 'submit',
|
|
14
|
+
target: el.shadowRoot.querySelector('form'),
|
|
15
|
+
preventDefault: () => {}
|
|
16
|
+
};
|
|
17
|
+
submitEvent.currentTarget = submitEvent.target;
|
|
18
|
+
|
|
19
|
+
urlInput.value = 'archive';
|
|
20
|
+
el.validateURL(submitEvent);
|
|
21
|
+
|
|
22
|
+
await el.updateComplete;
|
|
23
|
+
|
|
24
|
+
expect(el.inputValid).to.be.false;
|
|
25
|
+
expect(errorMessage.getAttribute('class')).to.contain('visible');
|
|
26
|
+
|
|
27
|
+
urlInput.value += '.org';
|
|
28
|
+
el.validateURL(submitEvent);
|
|
29
|
+
|
|
30
|
+
await el.updateComplete;
|
|
31
|
+
|
|
32
|
+
expect(el.inputValid).to.be.true;
|
|
33
|
+
expect(errorMessage.getAttribute('class')).not.to.contain('visible');
|
|
34
|
+
});
|
|
35
|
+
});
|