11import { mount } from '@vue/test-utils'
22import { nextTick } from 'vue'
3- import { describe , expect , it } from 'vitest'
3+ import { afterEach , describe , expect , it , vi } from 'vitest'
44
55import SurfaceActLine from '../SurfaceActLine.vue'
66import SurfaceActStream from '../SurfaceActStream.vue'
@@ -26,7 +26,11 @@ function makeAct(id: string, height: number, signer: string) {
2626}
2727
2828describe ( 'SurfaceActStream' , ( ) => {
29- it ( 'renders the oldest-to-newest five-record window with assertions and limited proof' , async ( ) => {
29+ afterEach ( ( ) => {
30+ vi . unstubAllGlobals ( )
31+ } )
32+
33+ it ( 'renders the oldest-to-newest desktop window with assertions and limited proof' , async ( ) => {
3034 const oldest = makeAct ( 'TX-1' , 1 , 'axone1oldest' )
3135 const newest = makeAct ( 'TX-2' , 2 , 'axone1newest' )
3236 const wrapper = mount ( SurfaceActStream , {
@@ -73,13 +77,16 @@ describe('SurfaceActStream', () => {
7377 expect ( wrapper . findAll ( '.surface-act-cursor' ) ) . toHaveLength ( 1 )
7478 } )
7579
76- it ( 'retains only the five latest records' , async ( ) => {
80+ it ( 'retains only the eight latest desktop records' , async ( ) => {
7781 const acts = [
78- makeAct ( 'TX-6' , 6 , 'axone1newest' ) ,
79- makeAct ( 'TX-5' , 5 , 'axone1middle' ) ,
80- makeAct ( 'TX-4' , 4 , 'axone1older' ) ,
81- makeAct ( 'TX-3' , 3 , 'axone1old' ) ,
82- makeAct ( 'TX-2' , 2 , 'axone1earlier' ) ,
82+ makeAct ( 'TX-9' , 9 , 'axone1newest' ) ,
83+ makeAct ( 'TX-8' , 8 , 'axone1eight' ) ,
84+ makeAct ( 'TX-7' , 7 , 'axone1seven' ) ,
85+ makeAct ( 'TX-6' , 6 , 'axone1six' ) ,
86+ makeAct ( 'TX-5' , 5 , 'axone1five' ) ,
87+ makeAct ( 'TX-4' , 4 , 'axone1four' ) ,
88+ makeAct ( 'TX-3' , 3 , 'axone1three' ) ,
89+ makeAct ( 'TX-2' , 2 , 'axone1two' ) ,
8390 makeAct ( 'TX-1' , 1 , 'axone1oldest' ) ,
8491 ]
8592 const wrapper = mount ( SurfaceActStream , {
@@ -88,9 +95,35 @@ describe('SurfaceActStream', () => {
8895
8996 await nextTick ( )
9097
91- expect ( wrapper . findAll ( '.surface-act-record' ) ) . toHaveLength ( 5 )
98+ expect ( wrapper . findAll ( '.surface-act-record' ) ) . toHaveLength ( 8 )
9299 expect ( wrapper . text ( ) ) . not . toContain ( 'axone1oldest' )
93- expect ( wrapper . text ( ) ) . toContain ( 'axone1older ' )
100+ expect ( wrapper . text ( ) ) . toContain ( 'axone1two ' )
94101 expect ( wrapper . text ( ) ) . toContain ( 'axone1newest' )
95102 } )
103+
104+ it ( 'shows only the five latest records on compact viewports' , async ( ) => {
105+ vi . stubGlobal (
106+ 'matchMedia' ,
107+ vi . fn ( ) . mockReturnValue ( {
108+ matches : true ,
109+ addEventListener : ( ) => undefined ,
110+ removeEventListener : ( ) => undefined ,
111+ } ) ,
112+ )
113+ const acts = Array . from ( { length : 8 } , ( _ , index ) => {
114+ const height = 8 - index
115+ return makeAct ( `TX-${ height } ` , height , `axone1${ height } ` )
116+ } )
117+ const wrapper = mount ( SurfaceActStream , {
118+ props : { acts, loading : false , reducedMotion : true , polling : false } ,
119+ } )
120+
121+ await nextTick ( )
122+ await nextTick ( )
123+
124+ expect ( wrapper . findAll ( '.surface-act-record' ) ) . toHaveLength ( 5 )
125+ expect ( wrapper . text ( ) ) . not . toContain ( 'axone11' )
126+ expect ( wrapper . text ( ) ) . toContain ( 'axone14' )
127+ expect ( wrapper . text ( ) ) . toContain ( 'axone18' )
128+ } )
96129} )
0 commit comments