Files
psf-memo-client/test/property/set-name.property.test.js
T
Chris Troutner 0159119921 Reduce DRY duplication in unit and property tests
Extract shared test helpers for the Memo post and Set Name behavior
slices: fake wallet/profiles, MemoAction tests, page-controller tests,
page build wiring, and shared property-test invariants. Behavior is
preserved; all unit, property, and acceptance tests pass.

By refactorer.
2026-08-25 20:30:24 -07:00

46 lines
1.2 KiB
JavaScript

/*
Property tests for the Set Name behavior slice.
These assert useful invariants that unit tests cover only at a few fixed
points. The validation, counter-conservation, setInput round-trip, and
broadcast-failure invariants are shared with the Memo post slice and live in
behavior-helpers.js; this file supplies the Set Name specifics.
*/
'use strict'
const { seededRandom } = require('./harness')
const { registerBehaviorProperties } = require('./behavior-helpers')
const { fakeProfiles } = require('../helpers/fake-profiles')
const MemoSetName = require('../../src/services/memo-set-name')
const SetNamePage = require('../../src/services/set-name-page')
const MAX = MemoSetName.MAX_NAME_BYTES // 77
const rng = seededRandom(20260827)
function buildPage () {
return new SetNamePage({
memoSetName: new MemoSetName({}),
navigate: () => {}
})
}
function buildBroadcastPage ({ wallet, navigations }) {
return new SetNamePage({
memoSetName: new MemoSetName({ wallet, profiles: fakeProfiles() }),
navigate: (p) => navigations.push(p)
})
}
registerBehaviorProperties({
Module: MemoSetName,
MAX,
label: 'set-name',
rng,
measure: (input) => Buffer.byteLength(input, 'utf8'),
buildPage,
buildBroadcastPage
})