Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #933, manifest display debugString. Add test coverage. #950

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lighthouse-core/audits/manifest-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ class ManifestDisplay extends Audit {

const hasRecommendedValue = ManifestDisplay.hasRecommendedValue(displayValue);

return ManifestDisplay.generateAuditResult({
const auditResult = ManifestDisplay.generateAuditResult({
rawValue: hasRecommendedValue,
displayValue,
debugString: 'Manifest display property should be set.'
displayValue
});
if (!hasRecommendedValue) {
auditResult.debugString = 'Manifest display property should be set.';
}
return auditResult;
}

static createDebugString(hasRecValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this now :)

const debugString = 'Manifest display property should be set.';
return hasRecValue ? undefined : debugString;
}
}

Expand Down
8 changes: 5 additions & 3 deletions lighthouse-core/test/audits/display-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ describe('Mobile-friendly: display audit', () => {
});

it('fails when no manifest artifact present', () => {
return assert.equal(Audit.audit({Manifest: {
value: undefined
}}).rawValue, false);
const output = Audit.audit({Manifest: {value: undefined}});
assert.equal(output.rawValue, false);
assert.equal(output.debugString && output.debugString.length > 0, true);
});

it('falls back to the successful default when there is no manifest display property', () => {
Expand All @@ -49,6 +49,7 @@ describe('Mobile-friendly: display audit', () => {
assert.equal(output.score, true);
assert.equal(output.displayValue, 'browser');
assert.equal(output.rawValue, true);
assert.equal(output.debugString, undefined);
});

it('succeeds when a manifest has a display property', () => {
Expand All @@ -61,6 +62,7 @@ describe('Mobile-friendly: display audit', () => {
assert.equal(output.score, true);
assert.equal(output.displayValue, 'standalone');
assert.equal(output.rawValue, true);
assert.equal(output.debugString, undefined);
});

it('succeeds when a complete manifest contains a display property', () => {
Expand Down