fleet/frontend/layouts/CoreLayout/CoreLayout.tests.jsx
Mike Stone e565e03130 License features (#1134)
* API client to create and get an app license

* Fixes unhandled promise rejection errors in redux config

* License Page and Form

* Adds getLicense action

* Adds License key area to App Settings Form

* Use license.token instead of license.license

* Implement API client

* Adds key icon to License Form

* Adds License Success component

* Render License Success on License Page when there is a license

* Adds persistent flash actions and reducer to redux

* Adds nag message middleware

* Moves FlashMessage component to flash_message directory

* Adds Persistent Flash component

* Renders Persistent Flash component from Core Layout

* Adds Kyle's styles

* Change license validation message

* Finishing touches for app config form license area

* Handle revoked licenses

* License Page hits setup endpoint

* Display server errors on license form

* Changes 0 allowed hosts to unlimited

* Trims JWT token before sending to the server

* GET setup page after submitting license
2017-02-09 22:16:51 -05:00

77 lines
2.1 KiB
JavaScript

import expect from 'expect';
import { mount } from 'enzyme';
import helpers from 'test/helpers';
import { userStub } from 'test/stubs';
import CoreLayout from './CoreLayout';
const {
connectedComponent,
reduxMockStore,
} = helpers;
describe('CoreLayout - layouts', () => {
const store = {
app: { config: {} },
auth: { user: userStub },
notifications: {},
persistentFlash: {
showFlash: false,
message: '',
},
};
const mockStore = reduxMockStore(store);
it('renders the FlashMessage component when notifications are present', () => {
const storeWithNotifications = {
app: { config: {} },
auth: {
user: userStub,
},
notifications: {
alertType: 'success',
isVisible: true,
message: 'nice jerb!',
},
persistentFlash: {
showFlash: false,
message: '',
},
};
const mockStoreWithNotifications = reduxMockStore(storeWithNotifications);
const componentWithFlash = connectedComponent(CoreLayout, {
mockStore: mockStoreWithNotifications,
});
const componentWithoutFlash = connectedComponent(CoreLayout, {
mockStore,
});
const appWithFlash = mount(componentWithFlash);
const appWithoutFlash = mount(componentWithoutFlash);
expect(appWithFlash.length).toEqual(1);
expect(appWithoutFlash.length).toEqual(1);
expect(appWithFlash.find('FlashMessage').html()).toExist();
expect(appWithoutFlash.find('FlashMessage').html()).toNotExist();
});
it('renders the PersistentFlash component when showFlash is true', () => {
const storeWithPersistentFlash = {
...store,
persistentFlash: {
showFlash: true,
message: 'This is the flash message',
},
};
const mockStoreWithPersistentFlash = reduxMockStore(storeWithPersistentFlash);
const Layout = connectedComponent(CoreLayout, {
mockStore: mockStoreWithPersistentFlash,
});
const MountedLayout = mount(Layout);
expect(MountedLayout.find('PersistentFlash').length).toEqual(1, 'Expected the Persistent Flash to be on the page');
});
});