# Prompt — Generate Jest tests (test)

> Generated by orbit:prompt-generator for `cordova-plugin-insider`. Target tool: Claude Code. Based on `.orbit-output/config/architecture/` and `.claude/rules/unit-tests.md`.

---

```xml
<context>
Project: cordova-plugin-insider (Cordova bridge plugin). Tests cover the JavaScript bridge layer (js/) only; native code is not unit-tested here.
Read first: @.claude/rules/unit-tests.md.

Test stack: Jest 30, testEnvironment 'node', transform babel-jest. Tests live in __tests__/ and import sources directly, e.g. const Utils = require('../js/Utils').

FIRST DECIDE THE GROUP (see @.claude/rules/unit-tests.md §0). If the test drives a production singleton — js/InsiderPlugin (the global Insider), js/InsiderAppCards, js/InsiderEvents — the file MUST be named *.integration.test.js. Otherwise it is unit. The unit group is subtractive, so a misfiled test still runs and still passes: an untagged file that drives the production singleton is a DEFECT, caught only by devops/check_test_groups.sh. Mocking Utils/cordova.exec does not decide the group; what the call drives does.

Cordova is not present in node. jest.setup.js provides one shared test double (cordova === window.cordova; exec calls its success callback; document.addEventListener is a jest.fn) and jest.harness.js resets it before every test, with platformId back to 'android'. Every Utils function is a call-through spy of the real implementation — assert on it or override it per case (Utils.checkParameters.mockReturnValueOnce(true)). NEVER assign global.cordova / global.window or jest.mock('../js/Utils') in a test file. Set cordova.platformId inside a test for platform branches; simulate a native failure with cordova.exec.mockImplementationOnce((success, error) => error('err')).
</context>

<task>
Write Jest tests for: {{module_or_method}}.
Source file: {{path}}
</task>

<requirements>
- Mirror existing structure: describe per module, nested describe per method, behavior-style test names ("should ... when ...").
- Assert exact shapes with toEqual for the typed serialization contract ({ key, type, value }).
- Cover: happy path, each invalid-input branch (validation bails, no native call), serialization edge cases (dates → epoch-ms string, booleans → lowercased string, numeric_array/string_array), and platform branching (no-op on wrong platform).
- For App Cards: assert the right InsiderAppCardsError/code is thrown/rejected.
- Tests must pass on first run with `npm test`.
- Name the file for its group, and confirm `bash devops/check_test_groups.sh` stays green.
</requirements>

<constraints>
- Don't test www/ — test the js/ source.
- Don't rely on a real Cordova runtime; mock cordova.exec.
- Match the assertion style in __tests__/Utils.test.js.
</constraints>

<output_format>
1. Complete test file(s) under __tests__/.
2. List of scenarios covered.
3. Confirm `npm test` is expected green.
</output_format>
```

## Context files to include
| File | Reason |
|------|--------|
| `__tests__/Utils.test.js` | Canonical test/assertion style |
| the source under test (e.g. `js/User.js`) | What to cover |
| `js/Utils.js` | Validation + serialization contract |
| `jest.config.js` | Test config |
