From e61bb62e706ad33b6d82d8c95916804a709cd7d8 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 4 May 2017 18:12:18 -0700 Subject: [PATCH] tests. --- lighthouse-core/gather/gather-runner.js | 4 ---- .../test/gather/gather-runner-test.js | 22 ++++++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lighthouse-core/gather/gather-runner.js b/lighthouse-core/gather/gather-runner.js index 59108ca0c8fa..70d0aaa37dce 100644 --- a/lighthouse-core/gather/gather-runner.js +++ b/lighthouse-core/gather/gather-runner.js @@ -117,10 +117,6 @@ class GatherRunner { .then(_ => driver.enableRuntimeEvents()) .then(_ => driver.cacheNatives()) .then(_ => driver.dismissJavaScriptDialogs()) -<<<<<<< HEAD -======= - .then(_ => resetStorage && driver.cleanBrowserCaches()) ->>>>>>> Don't disable disk cache, just clear it once for perf. .then(_ => resetStorage && driver.clearDataForOrigin(options.url)) .then(_ => driver.blockUrlPatterns(options.flags.blockedUrlPatterns || [])) .then(_ => gathererResults.UserAgent = [driver.getUserAgent()]); diff --git a/lighthouse-core/test/gather/gather-runner-test.js b/lighthouse-core/test/gather/gather-runner-test.js index 7ad4800c4569..f41544e7e7fa 100644 --- a/lighthouse-core/test/gather/gather-runner-test.js +++ b/lighthouse-core/test/gather/gather-runner-test.js @@ -242,10 +242,10 @@ describe('GatherRunner', function() { }); }); - it('clears the network cache and origin storage', () => { + it('clears origin storage', () => { const asyncFunc = () => Promise.resolve(); const tests = { - calledDisableNetworkCache: false, + calledCleanBrowserCaches: false, calledClearStorage: false, }; const createCheck = variable => () => { @@ -259,22 +259,22 @@ describe('GatherRunner', function() { dismissJavaScriptDialogs: asyncFunc, enableRuntimeEvents: asyncFunc, cacheNatives: asyncFunc, - cleanBrowserCaches: createCheck('calledDisableNetworkCache'), + cleanBrowserCaches: createCheck('calledCleanBrowserCaches'), clearDataForOrigin: createCheck('calledClearStorage'), blockUrlPatterns: asyncFunc, getUserAgent: asyncFunc, }; return GatherRunner.setupDriver(driver, {}, {flags: {}}).then(_ => { - assert.equal(tests.calledDisableNetworkCache, true); + assert.equal(tests.calledCleanBrowserCaches, false); assert.equal(tests.calledClearStorage, true); }); }); - it('does not clear the cache & storage when disable-storage-reset flag is set', () => { + it('does not clear origin storage with flag --disable-storage-reset', () => { const asyncFunc = () => Promise.resolve(); const tests = { - calledDisableNetworkCache: false, + calledCleanBrowserCaches: false, calledClearStorage: false, }; const createCheck = variable => () => { @@ -288,7 +288,7 @@ describe('GatherRunner', function() { dismissJavaScriptDialogs: asyncFunc, enableRuntimeEvents: asyncFunc, cacheNatives: asyncFunc, - cleanBrowserCaches: createCheck('calledDisableNetworkCache'), + cleanBrowserCaches: createCheck('calledCleanBrowserCaches'), clearDataForOrigin: createCheck('calledClearStorage'), blockUrlPatterns: asyncFunc, getUserAgent: asyncFunc, @@ -297,7 +297,7 @@ describe('GatherRunner', function() { return GatherRunner.setupDriver(driver, {}, { flags: {disableStorageReset: true} }).then(_ => { - assert.equal(tests.calledDisableNetworkCache, false); + assert.equal(tests.calledCleanBrowserCaches, false); assert.equal(tests.calledClearStorage, false); }); }); @@ -345,8 +345,9 @@ describe('GatherRunner', function() { new TestGatherer() ] }; + const flags = {}; - return GatherRunner.pass({driver, config}, {TestGatherer: []}).then(_ => { + return GatherRunner.pass({driver, config, flags}, {TestGatherer: []}).then(_ => { assert.equal(calledTrace, true); }); }); @@ -393,8 +394,9 @@ describe('GatherRunner', function() { new TestGatherer() ] }; + const flags = {}; - return GatherRunner.pass({driver, config}, {TestGatherer: []}).then(_ => { + return GatherRunner.pass({driver, config, flags}, {TestGatherer: []}).then(_ => { assert.equal(calledDevtoolsLogCollect, true); }); });