This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
forked from mattermost/mattermost-webapp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-12068] Add ability to remove custom branding image (mattermost#3207)
* [MM-12068] Added the ability to remove custom branding image * [MM-12068] Fixed lint error * [MM-12068] Update en.json * [MM-12068] Added styling that was accidently removed * [MM-12068] Addressed PR comments * [MM-12068] Fixed test case * [MM-12068] Addressed PR comments * [MM-12068] Fixed Asyncrhonous behaviour * [MM-12068] Add function comments * [MM-12068] Removed unnecessary code * [MM-12068] Fixed small code discrepancy * [MM-12068] Generalised code * [MM-12068] Address comments regarding incorrect ref handling and made more generalised * [MM-12068] Lint error fixes * [MM-12068] Addressed PR and used function pass instead of refs * [MM-12068] return error as object and refactor code * [MM-12068] Add unregister save action function * [MM-12068] Lint and snapshot fixes * add unit test
- Loading branch information
Showing
10 changed files
with
259 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
components/admin_console/brand_image_setting/brand_image_setting.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
|
||
import {uploadBrandImage, deleteBrandImage} from 'actions/admin_actions.jsx'; | ||
|
||
import BrandImageSetting from './brand_image_setting.jsx'; | ||
|
||
jest.mock('actions/admin_actions.jsx', () => ({ | ||
...jest.requireActual('actions/admin_actions.jsx'), | ||
uploadBrandImage: jest.fn(), | ||
deleteBrandImage: jest.fn(), | ||
})); | ||
|
||
describe('components/admin_console/brand_image_setting', () => { | ||
const baseProps = { | ||
disabled: false, | ||
setSaveNeeded: jest.fn(), | ||
registerSaveAction: jest.fn(), | ||
unRegisterSaveAction: jest.fn(), | ||
}; | ||
|
||
test('should have called deleteBrandImage or uploadBrandImage on save depending on component state', () => { | ||
const wrapper = shallow( | ||
<BrandImageSetting {...baseProps}/> | ||
); | ||
|
||
const instance = wrapper.instance(); | ||
|
||
wrapper.setState({deleteBrandImage: false, brandImage: 'brand_image_file'}); | ||
instance.handleSave(); | ||
expect(deleteBrandImage).toHaveBeenCalledTimes(0); | ||
expect(uploadBrandImage).toHaveBeenCalledTimes(1); | ||
|
||
wrapper.setState({deleteBrandImage: true, brandImage: null}); | ||
instance.handleSave(); | ||
expect(deleteBrandImage).toHaveBeenCalledTimes(1); | ||
expect(uploadBrandImage).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
Oops, something went wrong.