-
Notifications
You must be signed in to change notification settings - Fork 0
Testing
PkiStudioJS uses npm test to protect the public Core API, viewer package contract, OID resolver behavior, and important documentation promises.
Run the test suite from the main repository:
npm testThe command runs Node.js tests under test/*.test.js. The main test file is test/core-api.test.js.
The tests verify that the Core API can parse and serialize a minimal DER document:
SEQUENCE { INTEGER 1 }
They also verify that parsed nodes can be re-encoded and that getNodeBytes(nodes, nodeId) returns the DER bytes for a selected node subtree.
The tests cover automatic detection and decoding for common text inputs:
- HEX text such as
3003020101. - PEM text with
BEGINandENDmarkers.
These checks help preserve the behavior used by both the browser viewer and the reusable Core API.
The tests verify two OID lookup paths:
- Supplying an
oidNamesobject directly to Core serializers. - Supplying an
oidResolvercreated by@pkistudio/pkistudiojs/oid-resolver.
They also check that custom resolver entries can override bundled OID names and that unresolved OIDs return an empty string.
The tests verify that public version metadata stays synchronized across:
package.jsonapp/static/pkistudio-core.jsapp/static/pkistudio.jsREADME.md
This helps prevent releases where the package version, viewer version, Core API version, and documentation disagree.
The tests verify that @pkistudio/pkistudiojs/viewer can be imported in a Node-like module evaluation context. This protects the package contract that importing the viewer is safe even though init() still requires a browser DOM.
The tests also verify viewer exports such as:
versioncoreinitautoInit
The tests check that editable viewer mode is implemented and documented. This includes the editable: false initialization option and the setEditable(false) / setEditable(true) runtime control.
The tests check that DER inspector tag editing behavior is implemented and documented. This includes identifier class and tag index editing, validation against the selected universal tag, and error display behavior.
The tests verify that selected-node new-window actions use the configured newWindowUrl when supplied.
The tests verify that document actions such as save, close, expand all, and collapse all are disabled until data is loaded.
The tests verify that calling viewer.init() without a browser DOM throws a clear error message.
npm test is focused on API contracts and important source/documentation alignment. It does not replace full browser verification.
It does not currently cover:
- Full browser UI interaction flows.
- Visual regression checks.
- Cross-browser behavior.
- Large real-world certificate corpora.
- Drag-and-drop behavior.
- Clipboard permission behavior across browsers.
- Package tarball contents.
- GitHub release or npm publish workflows.
Use browser verification when changing user-facing viewer behavior, dialogs, menus, editing flows, drag-and-drop, or clipboard behavior.
Run syntax checks with:
npm run checkFor package or release-related changes, also run:
npm pack --dry-runUse the local static server when browser verification is needed:
node app/server.jsThen open:
http://localhost:8080/
Update this page when tests add or remove public API guarantees, documentation contract checks, package export checks, or important viewer behavior checks.