mirror of
https://github.com/stablyai/orca.git
synced 2026-09-29 16:02:50 +00:00
test(terminals): lock the root-state identity of the bailout
A `return {}` bailout keeps the map reference but still allocates a new
root state, so zustand walks every listener. Assert root identity too.
This commit is contained in:
@@ -70,6 +70,8 @@ describe('setTabPaneExpanded', () => {
|
||||
const store = createTestStore()
|
||||
store.getState().setTabPaneExpanded(TAB_ID, false)
|
||||
const before = store.getState().expandedPaneByTabId
|
||||
// Root identity too: returning `{}` keeps the map but allocates a new root, so zustand still walks every listener.
|
||||
const rootBefore = store.getState()
|
||||
const published = recordPublishedMapKeys(store)
|
||||
|
||||
for (let i = 0; i < NO_OP_WRITES; i += 1) {
|
||||
@@ -78,6 +80,7 @@ describe('setTabPaneExpanded', () => {
|
||||
|
||||
expect(published).toEqual([])
|
||||
expect(store.getState().expandedPaneByTabId).toBe(before)
|
||||
expect(store.getState()).toBe(rootBefore)
|
||||
})
|
||||
|
||||
it('costs no React commit in a map subscriber when the value is unchanged', () => {
|
||||
@@ -117,6 +120,7 @@ describe('setTabCanExpandPane', () => {
|
||||
const store = createTestStore()
|
||||
store.getState().setTabCanExpandPane(TAB_ID, false)
|
||||
const before = store.getState().canExpandPaneByTabId
|
||||
const rootBefore = store.getState()
|
||||
const published = recordPublishedMapKeys(store)
|
||||
|
||||
for (let i = 0; i < NO_OP_WRITES; i += 1) {
|
||||
@@ -125,6 +129,7 @@ describe('setTabCanExpandPane', () => {
|
||||
|
||||
expect(published).toEqual([])
|
||||
expect(store.getState().canExpandPaneByTabId).toBe(before)
|
||||
expect(store.getState()).toBe(rootBefore)
|
||||
})
|
||||
|
||||
it('costs no React commit in a map subscriber when the value is unchanged', () => {
|
||||
|
||||
Reference in New Issue
Block a user