From 7d7ef11d3d7e3ed17bfd36faf9fa16b3ac28de1f Mon Sep 17 00:00:00 2001 From: blend <151626101+blendtwenty@users.noreply.github.com> Date: Wed, 28 Feb 2024 16:40:56 +1100 Subject: [PATCH] Add tests; correct doge URI protocol; add data-attributes; --- src/components/doge-qr/demo/index.html | 28 ++++++++++++++++---------- src/components/doge-qr/doge-qr.js | 8 ++++---- src/components/doge-qr/test.html | 18 +++++++++++++++++ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/components/doge-qr/demo/index.html b/src/components/doge-qr/demo/index.html index c71793e..f24cbc4 100644 --- a/src/components/doge-qr/demo/index.html +++ b/src/components/doge-qr/demo/index.html @@ -56,8 +56,10 @@

Purpose

+ address="D89DhnsgKncmN12RejxudfU8AwXp3946q1" + theme="such-doge" + amount=5 + >
Such Doge @@ -66,8 +68,9 @@

Purpose

+ address="D89DhnsgKncmN12RejxudfU8AwXp3946q1" + theme="so-coin" + amount=5>
So Coin @@ -81,8 +84,9 @@

Very customize

+ address="D89DhnsgKncmN12RejxudfU8AwXp3946q1" + theme="much-dev" + amount=5>
Much Dev @@ -91,8 +95,9 @@

Very customize

+ address="D89DhnsgKncmN12RejxudfU8AwXp3946q1" + theme="very-community" + amount=5>
Very Community @@ -101,9 +106,10 @@

Very customize

+ img="dance.gif" + amount=5>
Such wow! @@ -139,7 +145,7 @@

Usage

- 3. Test your QR code is working before sharing it with others. It should lead you to a URL formatted like so: dogecoin://D89DhnsgKncmN12RejxudfU8AwXp3946q1?amount=100 + 3. Test your QR code is working before sharing it with others. It should lead you to a URL formatted like so: dogecoin:D89DhnsgKncmN12RejxudfU8AwXp3946q1?amount=100

diff --git a/src/components/doge-qr/doge-qr.js b/src/components/doge-qr/doge-qr.js index 5900dc8..8f21339 100644 --- a/src/components/doge-qr/doge-qr.js +++ b/src/components/doge-qr/doge-qr.js @@ -107,7 +107,7 @@ export class DogeQR extends LitElement { if (!this.address) { return "Address not provided." } - return `dogecoin://${this.address}${this.appendAmount()}` + return `dogecoin:${this.address}${this.appendAmount()}` } appendAmount() { @@ -125,8 +125,8 @@ export class DogeQR extends LitElement { data: this.generateQrValue(), imageOptions: { crossOrigin: "anonymous", - hideBackgroundDots: false, - imageSize: 0.5, + hideBackgroundDots: true, + imageSize: 0.4, margin: 0 }, ...this.applyTheme(), @@ -146,7 +146,7 @@ export class DogeQR extends LitElement { render() { return html` -
+
`; } diff --git a/src/components/doge-qr/test.html b/src/components/doge-qr/test.html index 770724b..45523dc 100644 --- a/src/components/doge-qr/test.html +++ b/src/components/doge-qr/test.html @@ -8,6 +8,24 @@ runTests(async () => { describe("DogeQR", () => { + it('produces a correctly formatted dogecoin URI when given an address', async () => { + const el = await fixture(html` + + `); + const expectedValue = 'dogecoin:foobar' + const div = el.shadowRoot.querySelector('.qr-container'); + expect(div.getAttribute('data-qr-value')).to.equal(expectedValue); + }) + + it('produces a correctly formatted dogecoin URI when given an address and amount', async () => { + const el = await fixture(html` + + `); + const expectedValue = 'dogecoin:foobar?amount=50' + const div = el.shadowRoot.querySelector('.qr-container'); + expect(div.getAttribute('data-qr-value')).to.equal(expectedValue); + }) + it('displays an SVG when an address is provided', async () => { const el = await fixture(html`