-
- Downloads
Bug 1825157 - Unify the fake pref implementations used in tests. r=nanj
Before this commit, the New Tab tests had two fake pref implementations: * The `Services.prefs` mock in `TEST_GLOBAL`, which stubbed out a handful of `nsIPrefBranch` methods. * `FakensIPrefBranch`, which mocked a different handful of `nsIPrefBranch` methods. This commit: * Consolidates the two fake implementations into the mock `FakensIPrefBranch` class. * Adds a `FakensIPrefService` subclass of `FakensIPrefBranch`, with additional methods specific to `nsIPrefService`. * Replaces `FakensIPrefBranch.prototype.prefs` with a new `FAKE_GLOBAL_PREFS` map. The new approach still lets tests change and clear prefs on existing instances of `FakensIPrefBranch` and its subclasses, but makes the shared state explicit. The old approach of mutating `FakensIPrefBranch.prototype.prefs` relied on a subtle quirk of `prefs` being shared by all instances of `FakensIPrefBranch` and its subclasses, and broke when setting `prefs` to a new, empty object. * Moves `{observe, ignore}Branch` into `FakePrefs`, since these are not part of the `nsIPrefBranch` interface. Differential Revision: https://phabricator.services.mozilla.com/D173897
Showing
- browser/components/newtab/test/unit/lib/ActivityStreamPrefs.test.js 1 addition, 1 deletion...mponents/newtab/test/unit/lib/ActivityStreamPrefs.test.js
- browser/components/newtab/test/unit/lib/DiscoveryStreamFeed.test.js 1 addition, 0 deletions...mponents/newtab/test/unit/lib/DiscoveryStreamFeed.test.js
- browser/components/newtab/test/unit/lib/TelemetryFeed.test.js 43 additions, 28 deletions...ser/components/newtab/test/unit/lib/TelemetryFeed.test.js
- browser/components/newtab/test/unit/lib/TopSitesFeed.test.js 2 additions, 2 deletionsbrowser/components/newtab/test/unit/lib/TopSitesFeed.test.js
- browser/components/newtab/test/unit/lib/TopStoriesFeed.test.js 11 additions, 8 deletions...er/components/newtab/test/unit/lib/TopStoriesFeed.test.js
- browser/components/newtab/test/unit/unit-entry.js 2 additions, 31 deletionsbrowser/components/newtab/test/unit/unit-entry.js
- browser/components/newtab/test/unit/utils.js 106 additions, 21 deletionsbrowser/components/newtab/test/unit/utils.js
Loading
Please register or sign in to comment