Skip to content

Commit

Permalink
Add and adjust cache-start-url test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Aug 5, 2016
1 parent 269b5a8 commit 81e98d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lighthouse-core/audits/cache-start-url.js
Expand Up @@ -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'
Expand All @@ -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(/\?$/, '');
Expand Down
28 changes: 11 additions & 17 deletions lighthouse-core/test/audits/cache-start-url.js
Expand Up @@ -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);
});

Expand All @@ -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', () => {
Expand Down

0 comments on commit 81e98d0

Please sign in to comment.