Skip to content

Commit

Permalink
DBW: fix pluralization of "resources" in report (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel authored and brendankenny committed Oct 13, 2016
1 parent 22c1fc5 commit ce70a1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lighthouse-core/audits/dobetterweb/uses-http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions lighthouse-core/test/audits/dobetterweb/uses-http2-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit ce70a1b

Please sign in to comment.