mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo-client.git
synced 2026-09-21 16:52:02 -07:00
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.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
|
||||
const { fakeWallet } = require('../helpers/fake-wallet')
|
||||
|
||||
// Build a page controller wired to a working action and a navigation recorder.
|
||||
// Both the New Post and Set Name pages extend PageController and take a single
|
||||
// action dependency plus a navigate callback, so the wiring is identical; only
|
||||
// the page-specific pieces differ. `cfg` supplies:
|
||||
// Page - the page controller class (NewPostPage or SetNamePage)
|
||||
// Action - the action class (MemoPost or MemoSetName)
|
||||
// actionKey - the page's action dependency key ('memoPost' or 'memoSetName')
|
||||
// storeKey - the action's store dependency key ('feed' or 'profiles')
|
||||
// storeFactory - () => a fresh store
|
||||
function buildPage ({ Page, Action, actionKey, storeKey, storeFactory }) {
|
||||
const wallet = fakeWallet()
|
||||
const store = storeFactory()
|
||||
const action = new Action({ wallet, [storeKey]: store })
|
||||
const navigations = []
|
||||
const page = new Page({
|
||||
[actionKey]: action,
|
||||
navigate: (path) => navigations.push(path)
|
||||
})
|
||||
return { wallet, store, action, page, navigations }
|
||||
}
|
||||
|
||||
module.exports = { buildPage }
|
||||
Reference in New Issue
Block a user