4
4
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
5
*/
6
6
7
- import PreloadLCPImage from '../../audits/preload -lcp-image.js' ;
7
+ import PrioritizeLcpImage from '../../audits/prioritize -lcp-image.js' ;
8
8
import { networkRecordsToDevtoolsLog } from '../network-records-to-devtools-log.js' ;
9
9
import { createTestTrace } from '../create-test-trace.js' ;
10
10
@@ -13,17 +13,19 @@ const mainDocumentNodeUrl = 'http://www.example.com:3000';
13
13
const scriptNodeUrl = 'http://www.example.com/script.js' ;
14
14
const imageUrl = 'http://www.example.com/image.png' ;
15
15
16
- describe ( 'Performance: preload -lcp audit' , ( ) => {
16
+ describe ( 'Performance: prioritize -lcp-image audit' , ( ) => {
17
17
const mockArtifacts = ( networkRecords , finalDisplayedUrl ) => {
18
18
return {
19
19
GatherContext : { gatherMode : 'navigation' } ,
20
20
traces : {
21
- [ PreloadLCPImage . DEFAULT_PASS ] : createTestTrace ( {
21
+ [ PrioritizeLcpImage . DEFAULT_PASS ] : createTestTrace ( {
22
22
traceEnd : 6e3 ,
23
23
largestContentfulPaint : 45e2 ,
24
24
} ) ,
25
25
} ,
26
- devtoolsLogs : { [ PreloadLCPImage . DEFAULT_PASS ] : networkRecordsToDevtoolsLog ( networkRecords ) } ,
26
+ devtoolsLogs : {
27
+ [ PrioritizeLcpImage . DEFAULT_PASS ] : networkRecordsToDevtoolsLog ( networkRecords ) ,
28
+ } ,
27
29
URL : {
28
30
requestedUrl : finalDisplayedUrl ,
29
31
mainDocumentUrl : finalDisplayedUrl ,
@@ -92,7 +94,7 @@ describe('Performance: preload-lcp audit', () => {
92
94
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
93
95
artifacts . TraceElements = [ ] ;
94
96
const context = { settings : { } , computedCache : new Map ( ) } ;
95
- const result = await PreloadLCPImage . audit ( artifacts , context ) ;
97
+ const result = await PrioritizeLcpImage . audit ( artifacts , context ) ;
96
98
expect ( result ) . toEqual ( {
97
99
score : null ,
98
100
notApplicable : true ,
@@ -104,7 +106,7 @@ describe('Performance: preload-lcp audit', () => {
104
106
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
105
107
artifacts . TraceElements [ 0 ] . type = 'text' ;
106
108
const context = { settings : { } , computedCache : new Map ( ) } ;
107
- const result = await PreloadLCPImage . audit ( artifacts , context ) ;
109
+ const result = await PrioritizeLcpImage . audit ( artifacts , context ) ;
108
110
expect ( result ) . toEqual ( {
109
111
score : null ,
110
112
notApplicable : true ,
@@ -121,7 +123,7 @@ describe('Performance: preload-lcp audit', () => {
121
123
imagePaintEvent . args . data . DOMNodeId = 1729 ;
122
124
123
125
const context = { settings : { } , computedCache : new Map ( ) } ;
124
- const results = await PreloadLCPImage . audit ( artifacts , context ) ;
126
+ const results = await PrioritizeLcpImage . audit ( artifacts , context ) ;
125
127
expect ( results . score ) . toEqual ( 1 ) ;
126
128
expect ( results . details . overallSavingsMs ) . toEqual ( 0 ) ;
127
129
expect ( results . details . items ) . toHaveLength ( 0 ) ;
@@ -132,7 +134,7 @@ describe('Performance: preload-lcp audit', () => {
132
134
networkRecords [ 3 ] . isLinkPreload = true ;
133
135
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
134
136
const context = { settings : { } , computedCache : new Map ( ) } ;
135
- const results = await PreloadLCPImage . audit ( artifacts , context ) ;
137
+ const results = await PrioritizeLcpImage . audit ( artifacts , context ) ;
136
138
expect ( results . score ) . toEqual ( 1 ) ;
137
139
expect ( results . details . overallSavingsMs ) . toEqual ( 0 ) ;
138
140
expect ( results . details . items ) . toHaveLength ( 0 ) ;
@@ -143,7 +145,7 @@ describe('Performance: preload-lcp audit', () => {
143
145
networkRecords [ 3 ] . protocol = 'data' ;
144
146
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
145
147
const context = { settings : { } , computedCache : new Map ( ) } ;
146
- const results = await PreloadLCPImage . audit ( artifacts , context ) ;
148
+ const results = await PrioritizeLcpImage . audit ( artifacts , context ) ;
147
149
expect ( results . score ) . toEqual ( 1 ) ;
148
150
expect ( results . details . overallSavingsMs ) . toEqual ( 0 ) ;
149
151
expect ( results . details . items ) . toHaveLength ( 0 ) ;
@@ -153,7 +155,7 @@ describe('Performance: preload-lcp audit', () => {
153
155
const networkRecords = mockNetworkRecords ( ) ;
154
156
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
155
157
const context = { settings : { } , computedCache : new Map ( ) } ;
156
- const results = await PreloadLCPImage . audit ( artifacts , context ) ;
158
+ const results = await PrioritizeLcpImage . audit ( artifacts , context ) ;
157
159
expect ( results . numericValue ) . toEqual ( 180 ) ;
158
160
expect ( results . details . overallSavingsMs ) . toEqual ( 180 ) ;
159
161
expect ( results . details . items [ 0 ] . url ) . toEqual ( imageUrl ) ;
@@ -175,7 +177,7 @@ describe('Performance: preload-lcp audit', () => {
175
177
networkRecords [ 3 ] . transferSize = 5 * 1000 * 1000 ;
176
178
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
177
179
const context = { settings : { } , computedCache : new Map ( ) } ;
178
- const results = await PreloadLCPImage . audit ( artifacts , context ) ;
180
+ const results = await PrioritizeLcpImage . audit ( artifacts , context ) ;
179
181
expect ( results . numericValue ) . toEqual ( 30 ) ;
180
182
expect ( results . details . overallSavingsMs ) . toEqual ( 30 ) ;
181
183
expect ( results . details . items [ 0 ] . url ) . toEqual ( imageUrl ) ;
@@ -187,7 +189,7 @@ describe('Performance: preload-lcp audit', () => {
187
189
networkRecords [ 2 ] . transferSize = 2 * 1000 * 1000 ;
188
190
const artifacts = mockArtifacts ( networkRecords , mainDocumentNodeUrl ) ;
189
191
const context = { settings : { } , computedCache : new Map ( ) } ;
190
- const results = await PreloadLCPImage . audit ( artifacts , context ) ;
192
+ const results = await PrioritizeLcpImage . audit ( artifacts , context ) ;
191
193
expect ( results . numericValue ) . toEqual ( 30 ) ;
192
194
expect ( results . details . overallSavingsMs ) . toEqual ( 30 ) ;
193
195
expect ( results . details . items [ 0 ] . url ) . toEqual ( imageUrl ) ;
0 commit comments