Skip to content

[Feature] Add unit tests for ReopenQRCode command #2797

Description

@ConnorQi01

Summary

The ReopenQRCode command in src/extension/commands/reopenQRCode.ts has no dedicated unit tests. Its success path creates an Expo QR Code webview and renders the current QR Code URL, while its failure path throws FailedToReopenQRCode when no URL is available.

Why this is useful

Reopening the Expo QR Code is a user-facing command, but its webview contract and missing-URL behavior are currently unguarded. Focused unit tests can cover both paths without launching Expo, creating a real webview, or generating a QR image.

Suggested scope

  • Add test/extension/commands/reopenQRCode.test.ts using the existing proxyquire + Sinon command-test pattern.
  • Stub getQRCodeUrl, QRCodeContentProvider, and the required vscode APIs before importing the command module.
  • Test when a QR Code URL exists: createWebviewPanel is called with the expected view type, title, column, and options.
  • Verify the URL is parsed, passed to provideTextDocumentContent, and the returned HTML is assigned to the webview.
  • Test when no QR Code URL exists: baseFn() rejects with InternalErrorCode.FailedToReopenQRCode and no webview is created.

Evidence

  • src/extension/commands/reopenQRCode.ts contains distinct URL-present and URL-missing branches.
  • The current test suite only checks that reactNative.reopenQRCode is registered; it does not exercise ReopenQRCode.baseFn().
  • Latest master contains no dedicated reopenQRCode.test.ts.
  • No open issue or open PR currently covers this test gap.

Validation

  • Run npm run build.
  • Run the focused ReopenQRCode test suite.
  • Run npm test and confirm the new tests pass with the existing suite.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions