|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 | + * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | +/* global describe, before, after, it */ |
| 5 | + |
| 6 | +const mockery = require('mockery') |
| 7 | +const {mount} = require('enzyme') |
| 8 | +const assert = require('assert') |
| 9 | +const fakeElectron = require('../../../../lib/fakeElectron') |
| 10 | +let AdvancedTab |
| 11 | +require('../../../../braveUnit') |
| 12 | + |
| 13 | +describe('AdvancedTab component', function () { |
| 14 | + before(function () { |
| 15 | + mockery.enable({ |
| 16 | + warnOnReplace: false, |
| 17 | + warnOnUnregistered: false, |
| 18 | + useCleanCache: true |
| 19 | + }) |
| 20 | + mockery.registerMock('../../less/switchControls.less', {}) |
| 21 | + mockery.registerMock('../../less/about/preferences.less', {}) |
| 22 | + mockery.registerMock('../../less/forms.less', {}) |
| 23 | + mockery.registerMock('../../less/button.less', {}) |
| 24 | + mockery.registerMock('../../node_modules/font-awesome/css/font-awesome.css', {}) |
| 25 | + mockery.registerMock('../../../extensions/brave/img/caret_down_grey.svg') |
| 26 | + |
| 27 | + // default platformUtil to non-Linux |
| 28 | + mockery.registerMock('../../../common/lib/platformUtil', {isLinux: () => false}) |
| 29 | + |
| 30 | + mockery.registerMock('electron', fakeElectron) |
| 31 | + window.chrome = fakeElectron |
| 32 | + |
| 33 | + AdvancedTab = require('../../../../../../app/renderer/components/preferences/advancedTab') |
| 34 | + }) |
| 35 | + after(function () { |
| 36 | + mockery.disable() |
| 37 | + }) |
| 38 | + |
| 39 | + describe('AdvancedTab', function () { |
| 40 | + describe('previewReleases', function () { |
| 41 | + describe('on macOS', function () { |
| 42 | + it('is shown', function () { |
| 43 | + const wrapper = mount( |
| 44 | + <AdvancedTab onChangeSetting={null} /> |
| 45 | + ) |
| 46 | + const instance = wrapper.instance() |
| 47 | + assert(instance.previewReleases()) |
| 48 | + }) |
| 49 | + }) |
| 50 | + |
| 51 | + describe('on Linux', function () { |
| 52 | + before(function () { |
| 53 | + mockery.deregisterMock('../../../common/lib/platformUtil') |
| 54 | + mockery.registerMock('../../../common/lib/platformUtil', {isLinux: () => true}) |
| 55 | + mockery.resetCache() |
| 56 | + AdvancedTab = require('../../../../../../app/renderer/components/preferences/advancedTab') |
| 57 | + }) |
| 58 | + |
| 59 | + after(function () { |
| 60 | + mockery.deregisterMock('../../../common/lib/platformUtil') |
| 61 | + mockery.registerMock('../../../common/lib/platformUtil', {isLinux: () => false}) |
| 62 | + mockery.resetCache() |
| 63 | + AdvancedTab = require('../../../../../../app/renderer/components/preferences/advancedTab') |
| 64 | + }) |
| 65 | + |
| 66 | + it('is hidden', function () { |
| 67 | + const wrapper = mount( |
| 68 | + <AdvancedTab onChangeSetting={null} /> |
| 69 | + ) |
| 70 | + const instance = wrapper.instance() |
| 71 | + assert.equal(instance.previewReleases(), null) |
| 72 | + }) |
| 73 | + }) |
| 74 | + }) |
| 75 | + }) |
| 76 | +}) |
0 commit comments