Skip to content

Commit

Permalink
tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 5, 2017
1 parent c70f4cf commit e61bb62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 0 additions & 4 deletions lighthouse-core/gather/gather-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
Expand Down
22 changes: 12 additions & 10 deletions lighthouse-core/test/gather/gather-runner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => () => {
Expand All @@ -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 => () => {
Expand All @@ -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,
Expand All @@ -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);
});
});
Expand Down Expand Up @@ -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);
});
});
Expand Down Expand Up @@ -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);
});
});
Expand Down

0 comments on commit e61bb62

Please sign in to comment.