@@ -40,7 +40,7 @@ describe('record', () => {
40
40
} )
41
41
} )
42
42
43
- it ( 'captures stylesheet rules' , ( done ) => {
43
+ it ( 'captures stylesheet rules' , async ( ) => {
44
44
const styleElement = appendElement ( '<style></style>' ) as HTMLStyleElement
45
45
46
46
startRecording ( )
@@ -59,92 +59,88 @@ describe('record', () => {
59
59
styleSheet . insertRule ( 'body { color: #ccc; }' )
60
60
} , 10 )
61
61
62
- collectAsyncCalls ( emitSpy , recordsPerFullSnapshot ( ) + 6 , ( ) => {
63
- const records = getEmittedRecords ( )
64
- let i = 0
62
+ await collectAsyncCalls ( emitSpy , recordsPerFullSnapshot ( ) + 6 )
65
63
66
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Meta )
67
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Focus )
68
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . FullSnapshot )
64
+ const records = getEmittedRecords ( )
65
+ let i = 0
69
66
70
- if ( window . visualViewport ) {
71
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . VisualViewport )
72
- }
67
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Meta )
68
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Focus )
69
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . FullSnapshot )
73
70
74
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
75
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
76
- jasmine . objectContaining ( {
77
- source : IncrementalSource . StyleSheetRule ,
78
- adds : [ { rule : 'body { background: #000; }' , index : undefined } ] ,
79
- } )
80
- )
81
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
82
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
83
- jasmine . objectContaining ( {
84
- source : IncrementalSource . StyleSheetRule ,
85
- adds : [ { rule : 'body { background: #111; }' , index : undefined } ] ,
86
- } )
87
- )
88
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
89
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
90
- jasmine . objectContaining ( {
91
- source : IncrementalSource . StyleSheetRule ,
92
- removes : [ { index : 0 } ] ,
93
- } )
94
- )
95
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
96
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
97
- jasmine . objectContaining ( {
98
- source : IncrementalSource . StyleSheetRule ,
99
- adds : [ { rule : 'body { color: #fff; }' , index : undefined } ] ,
100
- } )
101
- )
102
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
103
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
104
- jasmine . objectContaining ( {
105
- source : IncrementalSource . StyleSheetRule ,
106
- removes : [ { index : 0 } ] ,
107
- } )
108
- )
109
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
110
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
111
- jasmine . objectContaining ( {
112
- source : IncrementalSource . StyleSheetRule ,
113
- adds : [ { rule : 'body { color: #ccc; }' , index : undefined } ] ,
114
- } )
115
- )
71
+ if ( window . visualViewport ) {
72
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . VisualViewport )
73
+ }
116
74
117
- done ( )
118
- } )
75
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
76
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
77
+ jasmine . objectContaining ( {
78
+ source : IncrementalSource . StyleSheetRule ,
79
+ adds : [ { rule : 'body { background: #000; }' , index : undefined } ] ,
80
+ } )
81
+ )
82
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
83
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
84
+ jasmine . objectContaining ( {
85
+ source : IncrementalSource . StyleSheetRule ,
86
+ adds : [ { rule : 'body { background: #111; }' , index : undefined } ] ,
87
+ } )
88
+ )
89
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
90
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
91
+ jasmine . objectContaining ( {
92
+ source : IncrementalSource . StyleSheetRule ,
93
+ removes : [ { index : 0 } ] ,
94
+ } )
95
+ )
96
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
97
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
98
+ jasmine . objectContaining ( {
99
+ source : IncrementalSource . StyleSheetRule ,
100
+ adds : [ { rule : 'body { color: #fff; }' , index : undefined } ] ,
101
+ } )
102
+ )
103
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
104
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
105
+ jasmine . objectContaining ( {
106
+ source : IncrementalSource . StyleSheetRule ,
107
+ removes : [ { index : 0 } ] ,
108
+ } )
109
+ )
110
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
111
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data ) . toEqual (
112
+ jasmine . objectContaining ( {
113
+ source : IncrementalSource . StyleSheetRule ,
114
+ adds : [ { rule : 'body { color: #ccc; }' , index : undefined } ] ,
115
+ } )
116
+ )
119
117
} )
120
118
121
- it ( 'flushes pending mutation records before taking a full snapshot' , ( done ) => {
119
+ it ( 'flushes pending mutation records before taking a full snapshot' , async ( ) => {
122
120
startRecording ( )
123
121
124
122
appendElement ( '<hr/>' )
125
123
126
124
// trigger full snapshot by starting a new view
127
125
newView ( )
128
126
129
- collectAsyncCalls ( emitSpy , 1 + 2 * recordsPerFullSnapshot ( ) , ( ) => {
130
- const records = getEmittedRecords ( )
131
- let i = 0
127
+ await collectAsyncCalls ( emitSpy , 1 + 2 * recordsPerFullSnapshot ( ) )
132
128
133
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Meta )
134
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Focus )
135
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . FullSnapshot )
129
+ const records = getEmittedRecords ( )
130
+ let i = 0
136
131
137
- if ( window . visualViewport ) {
138
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . VisualViewport )
139
- }
140
- expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
141
- expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data . source ) . toEqual ( IncrementalSource . Mutation )
142
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Meta )
143
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Focus )
144
- expect ( records [ i ++ ] . type ) . toEqual ( RecordType . FullSnapshot )
132
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Meta )
133
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Focus )
134
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . FullSnapshot )
145
135
146
- done ( )
147
- } )
136
+ if ( window . visualViewport ) {
137
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . VisualViewport )
138
+ }
139
+ expect ( records [ i ] . type ) . toEqual ( RecordType . IncrementalSnapshot )
140
+ expect ( ( records [ i ++ ] as BrowserIncrementalSnapshotRecord ) . data . source ) . toEqual ( IncrementalSource . Mutation )
141
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Meta )
142
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . Focus )
143
+ expect ( records [ i ++ ] . type ) . toEqual ( RecordType . FullSnapshot )
148
144
} )
149
145
150
146
describe ( 'Shadow dom' , ( ) => {
0 commit comments