* Use AppGroupId from Info.plists instead of hardcoded constant * Update script, ci & Makefile * Update Cocoapods to 1.9.3 * Split android builds using ABI filters * Update Fastlane deps & build scripts * Update CI to use latests scripts * Display app version & build number in select server screen * Make generate scripts compatible with node < 12 * Build scripts * add build script to package.json * Update to use bundler 2.1.4 and CI with Xcode 12 * Fix script name for build:ios-unsigned * Fix RN iOS scripts * Update CI pods-dependencies step * Add pipefail to android executor * Update Fastlane * Fix type in postinstall script * update android executor and set TERM * Fix S3 bucket name variable * Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * Fix master unit tests * use requireActual in jest setup * Jest setup to use react instead of React Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
79 lines
2.6 KiB
JavaScript
79 lines
2.6 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {shallow} from 'enzyme';
|
|
|
|
import InteractiveDialogController from './interactive_dialog_controller';
|
|
|
|
jest.mock('react-intl');
|
|
|
|
describe('InteractiveDialogController', () => {
|
|
test('should open interactive dialog as alert or screen depending on with or without element', () => {
|
|
let baseProps = getBaseProps('trigger_id_1');
|
|
const wrapper = shallow(
|
|
<InteractiveDialogController {...baseProps}/>,
|
|
{context: {intl: {formatMessage: jest.fn()}}},
|
|
);
|
|
|
|
const instance = wrapper.instance();
|
|
instance.showAlertDialog = jest.fn();
|
|
instance.showInteractiveDialogScreen = jest.fn();
|
|
|
|
expect(instance.showAlertDialog).toHaveBeenCalledTimes(0);
|
|
expect(instance.showInteractiveDialogScreen).toHaveBeenCalledTimes(0);
|
|
|
|
baseProps = getBaseProps('trigger_id_2');
|
|
wrapper.setProps({...baseProps});
|
|
expect(instance.showAlertDialog).toHaveBeenCalledTimes(1);
|
|
expect(instance.showAlertDialog).toHaveBeenCalledWith(baseProps.dialogData.dialog, baseProps.dialogData.url);
|
|
expect(instance.showInteractiveDialogScreen).toHaveBeenCalledTimes(0);
|
|
|
|
const elements = [{
|
|
data_source: '',
|
|
default: '',
|
|
display_name: 'Number',
|
|
help_text: '',
|
|
max_length: 0,
|
|
min_length: 0,
|
|
name: 'somenumber',
|
|
optional: false,
|
|
options: null,
|
|
placeholder: '',
|
|
subtype: 'number',
|
|
type: 'text',
|
|
}];
|
|
|
|
baseProps = getBaseProps('trigger_id_3', elements);
|
|
wrapper.setProps({...baseProps});
|
|
expect(instance.showAlertDialog).toHaveBeenCalledTimes(1);
|
|
expect(instance.showInteractiveDialogScreen).toHaveBeenCalledTimes(1);
|
|
expect(instance.showInteractiveDialogScreen).toHaveBeenCalledWith(baseProps.dialogData.dialog);
|
|
});
|
|
});
|
|
|
|
function getBaseProps(triggerId, elements, introductionText) {
|
|
const dialogData = {
|
|
dialog: {
|
|
callback_id: 'somecallbackid',
|
|
elements,
|
|
icon_url: 'icon_url',
|
|
notify_on_cancel: true,
|
|
state: 'somestate',
|
|
submit_label: 'Submit Test',
|
|
title: 'Dialog Test',
|
|
introductionText,
|
|
},
|
|
trigger_id: triggerId,
|
|
url: 'https://localhost:8065/dialog_submit',
|
|
};
|
|
|
|
return {
|
|
actions: {
|
|
submitInteractiveDialog: jest.fn(),
|
|
},
|
|
triggerId,
|
|
dialogData,
|
|
theme: {},
|
|
};
|
|
}
|