123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import React from 'react';
- import {mount} from 'enzyme';
- import ProjectPlugins from 'app/views/projectPlugins';
- import PluginNavigation from 'app/views/projectSettings/pluginNavigation';
- jest.mock('app/api');
- describe('PluginNavigation Integration', function() {
- let wrapper;
- let routerContext = TestStubs.routerContext();
- let org = routerContext.context.organization;
- let project = routerContext.context.project;
- let plugins = TestStubs.Plugins();
- beforeEach(function() {
- MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/integrations/`,
- method: 'GET',
- body: [],
- });
- MockApiClient.addMockResponse({
- url: `/organizations/${org.slug}/`,
- method: 'GET',
- body: {organization: org},
- });
- MockApiClient.addMockResponse({
- url: `/projects/${org.slug}/${project.slug}/plugins/`,
- method: 'GET',
- body: plugins,
- });
- MockApiClient.addMockResponse({
- url: `/projects/${org.slug}/${project.slug}/plugins/amazon-sqs/`,
- method: 'POST',
- });
- MockApiClient.addMockResponse({
- url: `/projects/${org.slug}/${project.slug}/plugins/github/`,
- method: 'DELETE',
- });
- });
- // Integration test with PluginNavigation
- describe('with PluginNavigation', function() {
- beforeEach(function() {
- let params = {orgId: org.slug, projectId: project.slug};
- let organization = {...org, id: org.slug, features: []};
- wrapper = mount(
- <div>
- <ProjectPlugins params={params} organization={organization} />
- <PluginNavigation organization={organization} urlRoot="/" />
- </div>,
- TestStubs.routerContext()
- );
- });
- it('has no items in <PluginNavigation />', function() {
- expect(wrapper.find('PluginNavigation a')).toHaveLength(0);
- });
- /**
- * This tests that ProjectPlugins and PluginNavigation respond to the same store
- */
- it('has Amazon in <PluginNavigation /> after enabling', async function() {
- await tick();
- wrapper.update();
- wrapper
- .find('Switch')
- .first()
- .simulate('click');
- await tick();
- wrapper.update();
- expect(wrapper.find('PluginNavigation').find('a')).toHaveLength(1);
- });
- });
- });
|