@ordergroove/offers 2.34.3 → 2.34.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordergroove/offers",
3
- "version": "2.34.3",
3
+ "version": "2.34.4",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "@ordergroove/offers-templates": "^0.9.1"
49
49
  },
50
- "gitHead": "d3e7deebb63e8f607ca07d7a0f1d298439c81449"
50
+ "gitHead": "cd24a15b855b86dd7f51d7bbbd3fa63f8d29f2c4"
51
51
  }
@@ -54,7 +54,12 @@ export class OptinButton extends OptinStatus {
54
54
  render() {
55
55
  return html`
56
56
  <slot name="default">
57
- <button aria-labelledby="ogOfferOptInLabel" class="btn radio ${this.subscribed ? 'active' : ''}"></button>
57
+ <button
58
+ aria-labelledby="ogOfferOptInLabel"
59
+ role="radio"
60
+ aria-checked="${!!this.subscribed}"
61
+ class="btn radio ${this.subscribed ? 'active' : ''}"
62
+ ></button>
58
63
  <label id="ogOfferOptInLabel">
59
64
  <slot>
60
65
  <slot name="label"><og-text key="offerOptInLabel"></og-text></slot>
@@ -19,7 +19,12 @@ export class OptoutButton extends OptinStatus {
19
19
  render() {
20
20
  return html`
21
21
  <slot name="default">
22
- <button aria-labelledby="ogOfferOptOutLabel" class="btn radio ${this.subscribed ? '' : 'active'}"></button>
22
+ <button
23
+ aria-labelledby="ogOfferOptOutLabel"
24
+ role="radio"
25
+ aria-checked="${!this.subscribed}"
26
+ class="btn radio ${this.subscribed ? '' : 'active'}"
27
+ ></button>
23
28
  <label id="ogOfferOptOutLabel">
24
29
  <slot>
25
30
  <og-text key="offerOptOutLabel"></og-text>
@@ -13,6 +13,22 @@ describe('OptinButton', function() {
13
13
  expect(querySelector(element, 'button.active')).toBeTruthy();
14
14
  });
15
15
 
16
+ it('should be aria-checked if subscribed', async () => {
17
+ const element = new OptinButton();
18
+ element.setAttribute('product', '123');
19
+ element.subscribed = true;
20
+ await appendToBody(element);
21
+ expect(querySelector(element, 'button').getAttribute('aria-checked')).toEqual('true');
22
+ });
23
+
24
+ it('should not be aria-checked if not subscribed', async () => {
25
+ const element = new OptinButton();
26
+ element.setAttribute('product', '123');
27
+ element.subscribed = false;
28
+ await appendToBody(element);
29
+ expect(querySelector(element, 'button').getAttribute('aria-checked')).toEqual('false');
30
+ });
31
+
16
32
  it('should show empty label if not subscribed', async () => {
17
33
  const element = new OptinButton();
18
34
  element.setAttribute('product', '123');
@@ -32,4 +32,20 @@ describe('OptoutButton', () => {
32
32
  await appendToBody(elm);
33
33
  expect(querySelector(elm, 'button.active')).toBeTruthy();
34
34
  });
35
+
36
+ it('should be aria-checked if subscribed', async () => {
37
+ const element = new OptoutButton();
38
+ element.setAttribute('product', '123');
39
+ element.subscribed = true;
40
+ await appendToBody(element);
41
+ expect(querySelector(element, 'button').getAttribute('aria-checked')).toEqual('false');
42
+ });
43
+
44
+ it('should not be aria-checked if not subscribed', async () => {
45
+ const element = new OptoutButton();
46
+ element.setAttribute('product', '123');
47
+ element.subscribed = false;
48
+ await appendToBody(element);
49
+ expect(querySelector(element, 'button').getAttribute('aria-checked')).toEqual('true');
50
+ });
35
51
  });