@@ -17,7 +17,7 @@ const Audit = require('../../audits/cache-start-url.js');
1717const assert = require ( 'assert' ) ;
1818const manifestSrc = JSON . stringify ( require ( '../fixtures/manifest.json' ) ) ;
1919const manifestParser = require ( '../../lib/manifest-parser' ) ;
20- const Manifest = manifestParser ( manifestSrc ) ;
20+ const exampleManifest = manifestParser ( manifestSrc ) ;
2121const CacheContents = [ 'https://another.example.com/' , 'https://example.com/' ] ;
2222const URL = 'https://example.com' ;
2323const AltURL = 'https://example.com/?utm_source=http203' ;
@@ -30,50 +30,42 @@ describe('Cache: start_url audit', () => {
3030 } ) ;
3131
3232 it ( 'fails when no cache contents given' , ( ) => {
33- return assert . equal ( Audit . audit ( { Manifest, URL } ) . rawValue , false ) ;
33+ const artifacts = { Manifest : exampleManifest , URL } ;
34+ const output = Audit . audit ( artifacts ) ;
35+ assert . equal ( output . rawValue , false ) ;
36+ assert . equal ( output . debugString , 'No cache or URL detected' ) ;
3437 } ) ;
3538
3639 it ( 'fails when no URL given' , ( ) => {
37- return assert . equal ( Audit . audit ( { Manifest, CacheContents} ) . rawValue , false ) ;
40+ const artifacts = { Manifest : exampleManifest , CacheContents} ;
41+ const output = Audit . audit ( artifacts ) ;
42+ assert . equal ( output . rawValue , false ) ;
43+ assert . equal ( output . debugString , 'No cache or URL detected' ) ;
3844 } ) ;
3945
4046 // Need to disable camelcase check for dealing with start_url.
4147 /* eslint-disable camelcase */
42- it ( 'fails when a manifest artifact contains no start_url' , ( ) => {
43- const inputs = {
44- Manifest : { }
45- } ;
46- return assert . equal ( Audit . audit ( inputs ) . rawValue , false ) ;
47- } ) ;
48-
49- it ( 'fails when a manifest artifact contains a null start_url' , ( ) => {
50- const inputs = {
51- Manifest : {
52- start_url : null
53- }
54- } ;
55- return assert . equal ( Audit . audit ( inputs ) . rawValue , false ) ;
56- } ) ;
57-
5848 it ( 'fails when a manifest contains no start_url' , ( ) => {
59- const inputs = {
60- Manifest : manifestParser ( { } )
49+ const artifacts = {
50+ Manifest : manifestParser ( '{}' )
6151 } ;
62- return assert . equal ( Audit . audit ( inputs ) . rawValue , false ) ;
52+ const output = Audit . audit ( artifacts ) ;
53+ assert . equal ( output . rawValue , false ) ;
54+ assert . equal ( output . debugString , 'start_url not present in Manifest' ) ;
6355 } ) ;
6456 /* eslint-enable camelcase */
6557
6658 it ( 'succeeds when given a manifest with a start_url, cache contents, and a URL' , ( ) => {
6759 return assert . equal ( Audit . audit ( {
68- Manifest,
60+ Manifest : exampleManifest ,
6961 CacheContents,
7062 URL
7163 } ) . rawValue , true ) ;
7264 } ) ;
7365
7466 it ( 'handles URLs with utm params' , ( ) => {
7567 return assert . equal ( Audit . audit ( {
76- Manifest,
68+ Manifest : exampleManifest ,
7769 CacheContents,
7870 URL : AltURL
7971 } ) . rawValue , true ) ;
0 commit comments