@carbon/ibm-cloud-cognitive-cdai
Version:
Carbon for Cloud & Cognitive CD&AI UI components
41 lines (40 loc) • 1.56 kB
JavaScript
//
// Copyright IBM Corp. 2020, 2020
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//
import { ErrorFilled16 } from '@carbon/icons-react';
import * as jth from '../../component_helpers/jest_test_helper_functions.js';
import { IdeAutoSave } from '.';
describe('IdeAutoSave', function () {
var unmount;
var mountTestComponent = function mountTestComponent() {
var defaultProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var test = jth.mountComponent(jth.getJSXForComponent(IdeAutoSave, defaultProps, props));
unmount = test.unmount;
return test.component;
};
afterEach(function () {
// if unmount defined, call it to clear up any mounted component
unmount && unmount();
});
it('renders default state', function () {
var wrapper = mountTestComponent({
state: 'default',
text: 'defaultText'
});
expect(wrapper.find('.ide-auto-save').length).toEqual(1);
expect(wrapper.find('.ide-auto-save__text').text()).toEqual('defaultText');
});
it('renders failed state with icon', function () {
var wrapper = mountTestComponent({
state: 'failed',
text: 'failedText'
});
expect(wrapper.find('.ide-auto-save').length).toEqual(1);
expect(wrapper.find(ErrorFilled16).length).toEqual(1);
expect(wrapper.find('.ide-auto-save__text').text()).toEqual('failedText');
});
});