diff --git a/lighthouse-core/audits/dobetterweb/uses-http2.js b/lighthouse-core/audits/dobetterweb/uses-http2.js index 075cf5dcac9a..5a523ae48d9e 100644 --- a/lighthouse-core/audits/dobetterweb/uses-http2.js +++ b/lighthouse-core/audits/dobetterweb/uses-http2.js @@ -70,8 +70,12 @@ class UsesHTTP2Audit extends Audit { }, record); }); - const displayValue = (resources.length ? - `${resources.length} resources were not served over h2` : ''); + let displayValue = ''; + if (resources.length > 1) { + displayValue = `${resources.length} resources were not served over h2`; + } else if (resources.length === 1) { + displayValue = `${resources.length} resource was not served over h2`; + } return UsesHTTP2Audit.generateAuditResult({ rawValue: resources.length === 0, diff --git a/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js b/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js index fa3ae01f932b..54eb1ee2ac45 100644 --- a/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js +++ b/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js @@ -41,6 +41,15 @@ describe('Resources are fetched over http/2', () => { assert.equal(auditResult.extendedInfo.value.length, 4); }); + it('displayValue is correct when only one resource fails', () => { + const entryWithHTTP1 = networkRecords.slice(1, 2); + const auditResult = UsesHTTP2Audit.audit({ + URL: {finalUrl: URL}, + networkRecords: {[UsesHTTP2Audit.DEFAULT_PASS]: entryWithHTTP1} + }); + assert.ok(auditResult.displayValue.match('1 resource was not')); + }); + it('passes when all resources were requested via http/2', () => { const auditResult = UsesHTTP2Audit.audit({ URL: {finalUrl: URL},