From 81e98d0d5d3beab171e6fc6a3ed70395ddb01cfb Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 4 Aug 2016 17:21:29 -0700 Subject: [PATCH] Add and adjust cache-start-url test coverage --- lighthouse-core/audits/cache-start-url.js | 4 +-- .../test/audits/cache-start-url.js | 28 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lighthouse-core/audits/cache-start-url.js b/lighthouse-core/audits/cache-start-url.js index e5424ab302d8..14f58ff160be 100644 --- a/lighthouse-core/audits/cache-start-url.js +++ b/lighthouse-core/audits/cache-start-url.js @@ -43,7 +43,7 @@ class CacheStartUrl extends Audit { const cacheContents = artifacts.CacheContents; const baseURL = artifacts.URL; - if (!(manifest && manifest.start_url && manifest.start_url.raw)) { + if (!(manifest && manifest.start_url && manifest.start_url.value)) { return CacheStartUrl.generateAuditResult({ rawValue: false, debugString: 'start_url not present in Manifest' @@ -58,7 +58,7 @@ class CacheStartUrl extends Audit { } // Remove any UTM strings. - const startURL = url.resolve(baseURL, manifest.start_url.raw).toString(); + const startURL = url.resolve(baseURL, manifest.start_url.value).toString(); const altStartURL = startURL .replace(/\?utm_([^=]*)=([^&]|$)*/, '') .replace(/\?$/, ''); diff --git a/lighthouse-core/test/audits/cache-start-url.js b/lighthouse-core/test/audits/cache-start-url.js index 7141e74fd415..b0cc2e525688 100644 --- a/lighthouse-core/test/audits/cache-start-url.js +++ b/lighthouse-core/test/audits/cache-start-url.js @@ -25,13 +25,7 @@ const AltURL = 'https://example.com/?utm_source=http203'; /* global describe, it*/ describe('Cache: start_url audit', () => { - it('fails when no manifest present', () => { - return assert.equal(Audit.audit({Manifest: { - value: undefined - }}).rawValue, false); - }); - - it('fails when an empty manifest is present', () => { + it('fails when an empty manifest artifact is present', () => { return assert.equal(Audit.audit({Manifest: {}}).rawValue, false); }); @@ -43,30 +37,30 @@ describe('Cache: start_url audit', () => { return assert.equal(Audit.audit({Manifest, CacheContents}).rawValue, false); }); - // Need to disable camelcase check for dealing with short_name. + // Need to disable camelcase check for dealing with start_url. /* eslint-disable camelcase */ - it('fails when a manifest contains no start_url', () => { + it('fails when a manifest artifact contains no start_url', () => { const inputs = { - Manifest: { - - } + Manifest: { } }; - return assert.equal(Audit.audit(inputs).rawValue, false); }); - // Need to disable camelcase check for dealing with short_name. - /* eslint-disable camelcase */ - it('fails when a manifest contains no start_url', () => { + it('fails when a manifest artifact contains a null start_url', () => { const inputs = { Manifest: { start_url: null } }; - return assert.equal(Audit.audit(inputs).rawValue, false); }); + it('fails when a manifest contains no start_url', () => { + const inputs = { + Manifest: manifestParser({}) + }; + return assert.equal(Audit.audit(inputs).rawValue, false); + }); /* eslint-enable camelcase */ it('succeeds when given a manifest with a start_url, cache contents, and a URL', () => {