-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrScanner.twd.test.tsx
More file actions
35 lines (29 loc) · 1.26 KB
/
qrScanner.twd.test.tsx
File metadata and controls
35 lines (29 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { describe, it } from "twd-js/runner";
import { twd, screenDom, userEvent } from "twd-js";
describe("QR Scanner Page", () => {
it("should display the QR scanner page", async () => {
twd.mockComponent("qrScanner", ({
onScan,
}: {
onScan: (detectedCodes: Array<{ rawValue: string }>) => void;
}) => {
return <div>
<button onClick={() => onScan([{ rawValue: "1234567890" }])}>QR code scanned mocked</button>
</div>;
});
await twd.visit("/qr-scanner");
const qrScanner = await screenDom.getByText("QR Code Scanner");
twd.should(qrScanner, "be.visible");
const qrScannerHeading = await screenDom.getByText("Scan QR Code");
twd.should(qrScannerHeading, "be.visible");
let detectedCodes = await screenDom.getByText("No codes detected yet");
twd.should(detectedCodes, "be.visible");
const qrCodeScannedButton = await screenDom.getByText("QR code scanned mocked");
twd.should(qrCodeScannedButton, "be.visible");
await userEvent.click(qrCodeScannedButton);
detectedCodes = await screenDom.getByText("1 code(s) detected");
twd.should(detectedCodes, "be.visible");
const detectedCode = await screenDom.getByText("1234567890");
twd.should(detectedCode, "be.visible");
});
});