원클릭으로
unit-test-patterns
// Code patterns and examples for Scopy IIOWidget unit tests. Covers standard helpers, data-driven testing, and complex multi-step scenarios. Auto-loads when creating or reviewing `*_Unit_test.js` files.
// Code patterns and examples for Scopy IIOWidget unit tests. Covers standard helpers, data-driven testing, and complex multi-step scenarios. Auto-loads when creating or reviewing `*_Unit_test.js` files.
Guidelines for using Context7, web search, and other research tools to find solutions outside the Scopy codebase. Loaded when the task involves unfamiliar technology or external libraries.
Core Scopy architecture knowledge including plugin lifecycle, library dependencies, build system, and key design patterns. Loaded by clarify-task and design-task commands.
How Scopy libraries depend on each other, plugin commonalities, MessageBroker topics, shared widgets, style system flow, and build system relationships. Loaded when determining component interactions or change impact.
Decision trees for common Scopy architectural choices - plugin vs core, tool vs section, widget type selection, sync vs async, GNU Radio vs direct, package organization, and API exposure. Loaded when making design decisions.
Catalog of all Scopy development tools including package generator, testing tools, CI scripts, format/license scripts, and dev plugin commands. Loaded when analyzing what tools exist for a task.
Unit test validation rules for Scopy plugin IIOWidget tests. Auto-loads when reviewing or writing `*_Unit_test.js` files.
| name | unit-test-patterns |
| description | Code patterns and examples for Scopy IIOWidget unit tests. Covers standard helpers, data-driven testing, and complex multi-step scenarios. Auto-loads when creating or reviewing `*_Unit_test.js` files. |
This skill provides code patterns for generating and reviewing JS unit tests that validate IIOWidget attributes in Scopy plugins. All examples are from the AD9371 reference implementation.
These helpers test individual widget attributes. Every unit test file must define and use them.
| Pattern | File | Widget Type | Description |
|---|---|---|---|
| testRange | test-range.md | Range/Spinbox | Write min/max/mid, verify readback with tolerance |
| testCombo | test-combo.md | Combo/Dropdown | Iterate valid options, verify exact match |
| testCheckbox | test-checkbox.md | Checkbox/Toggle | Toggle 0/1, verify readback |
| testReadOnly | test-readonly.md | Read-Only | Verify value is non-empty |
| testConversion | test-conversion.md | API + Widget | Validate API scaling vs raw widget value |
| testBadValueRange | test-bad-value-range.md | Range boundary | Verify above-max/below-min clamping |
| testBadValueCombo | test-bad-value-combo.md | Combo boundary | Verify invalid option rejection |
| testCalibrationFlag | test-calibration-flag.md | Calibration toggle | Test enable/disable via API getter/setter |
| runDataDrivenTests | data-driven-tests.md | Batch dispatch | Run array of test descriptors through helpers |
Multi-step scenarios that test functionality beyond single-widget read/write. Each pattern includes: when to use, API signature trigger, and complete code example.
| Pattern | File | Trigger |
|---|---|---|
| Calibration Flow | complex-calibration-flow.md | calibrate() exists in API |
| Profile Loading | complex-profile-loading.md | loadProfile() exists |
| Gain Mode Interaction | complex-gain-mode-interaction.md | getXxxGainControlMode() + setXxxHardwareGain() |
| State Transitions | complex-state-transitions.md | getEnsmMode()/setEnsmMode() |
| DPD Operations | complex-dpd-operations.md | dpdReset() + getDpdStatus() |
| Channel Independence | complex-channel-independence.md | Setter with int channel, count > 1 |
| Phase Rotation | complex-phase-rotation.md | getPhaseRotation()/setPhaseRotation() |
| Frequency Tuning | complex-frequency-tuning.md | Getter/setter with Hz-to-MHz conversion |
| UDC LO Splitting | complex-udc-lo-splitting.md | hasUdc()/getUdcEnabled() |
| Refresh Cycle | complex-refresh-cycle.md | refresh() exists |
| Reference | File |
|---|---|
| File Structure & Boilerplate | file-structure.md |
msleep(500) — no exceptionsrunDataDrivenTests() — for sections with 3+ widgets of the same typeUNIT.<SECTION>.<ATTRIBUTE_NAME> — uppercase, dots as separators<device-name>/<channel>/<attribute> or <device-name>/<attribute>