@spectrum-web-components/tooltip 0.10.6 → 0.10.7-express.9
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/package.json +4 -4
- package/test/tooltip.test-vrt.js +15 -0
- package/test/tooltip.test-vrt.js.map +1 -0
- package/test/tooltip.test.js +122 -0
- package/test/tooltip.test.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tooltip",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7-express.9+abfee7409",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@spectrum-web-components/base": "^0.5.2",
|
|
48
|
-
"@spectrum-web-components/overlay": "^0.14.
|
|
48
|
+
"@spectrum-web-components/overlay": "^0.14.2-express.9+abfee7409",
|
|
49
49
|
"tslib": "^2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@spectrum-css/tooltip": "^3.1.
|
|
52
|
+
"@spectrum-css/tooltip": "^3.1.8"
|
|
53
53
|
},
|
|
54
54
|
"types": "./src/index.d.ts",
|
|
55
55
|
"customElements": "custom-elements.json",
|
|
56
56
|
"sideEffects": [
|
|
57
57
|
"./sp-*.js"
|
|
58
58
|
],
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "abfee740957976448a3e4cf90df17d6165f857d6"
|
|
60
60
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import * as stories from '../stories/tooltip.stories.js';
|
|
13
|
+
import { regressVisuals } from '../../../test/visual/test.js';
|
|
14
|
+
regressVisuals('TooltipStories', stories);
|
|
15
|
+
//# sourceMappingURL=tooltip.test-vrt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.test-vrt.js","sourceRoot":"","sources":["tooltip.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/tooltip.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('TooltipStories', stories);\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import '../sp-tooltip.js';
|
|
13
|
+
import { elementUpdated, expect, fixture, html, oneEvent, } from '@open-wc/testing';
|
|
14
|
+
import '@spectrum-web-components/button/sp-button.js';
|
|
15
|
+
describe('Tooltip', () => {
|
|
16
|
+
it('loads', async () => {
|
|
17
|
+
const el = await fixture(html `
|
|
18
|
+
<sp-tooltip>Help text.</sp-tooltip>
|
|
19
|
+
`);
|
|
20
|
+
await elementUpdated(el);
|
|
21
|
+
await expect(el).to.be.accessible();
|
|
22
|
+
});
|
|
23
|
+
it('self manages', async () => {
|
|
24
|
+
const button = await fixture(html `
|
|
25
|
+
<sp-button>
|
|
26
|
+
This is a button.
|
|
27
|
+
<sp-tooltip self-managed>Help text.</sp-tooltip>
|
|
28
|
+
</sp-button>
|
|
29
|
+
`);
|
|
30
|
+
const el = button.querySelector('sp-tooltip');
|
|
31
|
+
await elementUpdated(el);
|
|
32
|
+
await expect(button).to.be.accessible();
|
|
33
|
+
const opened = oneEvent(button, 'sp-opened');
|
|
34
|
+
button.focus();
|
|
35
|
+
await opened;
|
|
36
|
+
await elementUpdated(el);
|
|
37
|
+
expect(el.open).to.be.true;
|
|
38
|
+
await expect(button).to.be.accessible();
|
|
39
|
+
const closed = oneEvent(button, 'sp-closed');
|
|
40
|
+
button.blur();
|
|
41
|
+
await closed;
|
|
42
|
+
await elementUpdated(el);
|
|
43
|
+
expect(el.open).to.be.false;
|
|
44
|
+
});
|
|
45
|
+
it('cleans up when self manages', async () => {
|
|
46
|
+
const button = await fixture(html `
|
|
47
|
+
<sp-button>
|
|
48
|
+
This is a button.
|
|
49
|
+
<sp-tooltip self-managed>Help text.</sp-tooltip>
|
|
50
|
+
</sp-button>
|
|
51
|
+
`);
|
|
52
|
+
const el = button.querySelector('sp-tooltip');
|
|
53
|
+
await elementUpdated(el);
|
|
54
|
+
const opened = oneEvent(button, 'sp-opened');
|
|
55
|
+
button.focus();
|
|
56
|
+
await opened;
|
|
57
|
+
await elementUpdated(el);
|
|
58
|
+
expect(el.open).to.be.true;
|
|
59
|
+
let activeOverlay = document.querySelector('active-overlay');
|
|
60
|
+
expect(activeOverlay).to.not.be.null;
|
|
61
|
+
const closed = oneEvent(button, 'sp-closed');
|
|
62
|
+
button.remove();
|
|
63
|
+
await closed;
|
|
64
|
+
activeOverlay = document.querySelector('active-overlay');
|
|
65
|
+
expect(activeOverlay).to.be.null;
|
|
66
|
+
});
|
|
67
|
+
it('accepts variants', async () => {
|
|
68
|
+
const el = await fixture(html `
|
|
69
|
+
<sp-tooltip variant="negative">Help text.</sp-tooltip>
|
|
70
|
+
`);
|
|
71
|
+
await elementUpdated(el);
|
|
72
|
+
expect(el.variant).to.equal('negative');
|
|
73
|
+
expect(el.getAttribute('variant')).to.equal('negative');
|
|
74
|
+
el.variant = 'info';
|
|
75
|
+
await elementUpdated(el);
|
|
76
|
+
expect(el.variant).to.equal('info');
|
|
77
|
+
expect(el.getAttribute('variant')).to.equal('info');
|
|
78
|
+
el.setAttribute('variant', 'positive');
|
|
79
|
+
await elementUpdated(el);
|
|
80
|
+
expect(el.variant).to.equal('positive');
|
|
81
|
+
expect(el.getAttribute('variant')).to.equal('positive');
|
|
82
|
+
el.removeAttribute('variant');
|
|
83
|
+
await elementUpdated(el);
|
|
84
|
+
expect(el.variant).to.equal('');
|
|
85
|
+
expect(el.hasAttribute('variant')).to.be.false;
|
|
86
|
+
});
|
|
87
|
+
it('validates variants', async () => {
|
|
88
|
+
const el = await fixture(html `
|
|
89
|
+
<sp-tooltip variant="other">Help text.</sp-tooltip>
|
|
90
|
+
`);
|
|
91
|
+
await elementUpdated(el);
|
|
92
|
+
expect(el.variant).to.equal('');
|
|
93
|
+
expect(el.hasAttribute('variant')).to.be.false;
|
|
94
|
+
el.variant = 'info';
|
|
95
|
+
await elementUpdated(el);
|
|
96
|
+
expect(el.variant).to.equal('info');
|
|
97
|
+
expect(el.getAttribute('variant')).to.equal('info');
|
|
98
|
+
el.variant = 'info';
|
|
99
|
+
await elementUpdated(el);
|
|
100
|
+
expect(el.variant).to.equal('info');
|
|
101
|
+
expect(el.getAttribute('variant')).to.equal('info');
|
|
102
|
+
});
|
|
103
|
+
it('answers tip query', async () => {
|
|
104
|
+
const el = await fixture(html `
|
|
105
|
+
<sp-tooltip placement="top">Help text.</sp-tooltip>
|
|
106
|
+
`);
|
|
107
|
+
await elementUpdated(el);
|
|
108
|
+
const overlayDetailQuery = {};
|
|
109
|
+
const queryOverlayDetailEvent = new CustomEvent('sp-overlay-query', {
|
|
110
|
+
bubbles: true,
|
|
111
|
+
composed: true,
|
|
112
|
+
detail: overlayDetailQuery,
|
|
113
|
+
cancelable: true,
|
|
114
|
+
});
|
|
115
|
+
el.dispatchEvent(queryOverlayDetailEvent);
|
|
116
|
+
expect(overlayDetailQuery.overlayContentTipElement).to.exist;
|
|
117
|
+
if (overlayDetailQuery.overlayContentTipElement) {
|
|
118
|
+
expect(overlayDetailQuery.overlayContentTipElement.id).to.equal('tip');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=tooltip.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.test.js","sourceRoot":"","sources":["tooltip.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,kBAAkB,CAAC;AAG1B,OAAO,EACH,cAAc,EACd,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,GACX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,8CAA8C,CAAC;AAEtD,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EA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E,CAAC,CAAC,EAAE,CAAC,KAAK,CAC3D,KAAK,CACR,CAAC;SACL;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '../sp-tooltip.js';\nimport { Tooltip } from '../';\nimport { OverlayDisplayQueryDetail } from '@spectrum-web-components/overlay';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n} from '@open-wc/testing';\nimport { Button } from '@spectrum-web-components/button';\nimport '@spectrum-web-components/button/sp-button.js';\n\ndescribe('Tooltip', () => {\n it('loads', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip>Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('self manages', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n await expect(button).to.be.accessible();\n\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n await expect(button).to.be.accessible();\n\n const closed = oneEvent(button, 'sp-closed');\n button.blur();\n await closed;\n await elementUpdated(el);\n\n expect(el.open).to.be.false;\n });\n it('cleans up when self manages', async () => {\n const button = await fixture<Button>(\n html`\n <sp-button>\n This is a button.\n <sp-tooltip self-managed>Help text.</sp-tooltip>\n </sp-button>\n `\n );\n\n const el = button.querySelector('sp-tooltip') as Tooltip;\n\n await elementUpdated(el);\n\n const opened = oneEvent(button, 'sp-opened');\n button.focus();\n await opened;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n let activeOverlay = document.querySelector('active-overlay');\n expect(activeOverlay).to.not.be.null;\n\n const closed = oneEvent(button, 'sp-closed');\n button.remove();\n await closed;\n\n activeOverlay = document.querySelector('active-overlay');\n expect(activeOverlay).to.be.null;\n });\n it('accepts variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"negative\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('negative');\n expect(el.getAttribute('variant')).to.equal('negative');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.setAttribute('variant', 'positive');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('positive');\n expect(el.getAttribute('variant')).to.equal('positive');\n\n el.removeAttribute('variant');\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n });\n it('validates variants', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip variant=\"other\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('');\n expect(el.hasAttribute('variant')).to.be.false;\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n\n el.variant = 'info';\n\n await elementUpdated(el);\n\n expect(el.variant).to.equal('info');\n expect(el.getAttribute('variant')).to.equal('info');\n });\n\n it('answers tip query', async () => {\n const el = await fixture<Tooltip>(\n html`\n <sp-tooltip placement=\"top\">Help text.</sp-tooltip>\n `\n );\n\n await elementUpdated(el);\n\n const overlayDetailQuery: OverlayDisplayQueryDetail = {};\n const queryOverlayDetailEvent =\n new CustomEvent<OverlayDisplayQueryDetail>('sp-overlay-query', {\n bubbles: true,\n composed: true,\n detail: overlayDetailQuery,\n cancelable: true,\n });\n el.dispatchEvent(queryOverlayDetailEvent);\n\n expect(overlayDetailQuery.overlayContentTipElement).to.exist;\n if (overlayDetailQuery.overlayContentTipElement) {\n expect(overlayDetailQuery.overlayContentTipElement.id).to.equal(\n 'tip'\n );\n }\n });\n});\n"]}
|