Test initial route

Add a test case to assert that the initial route is set to /all when the
app loads.
parent 72c4adbc
import { GlSprintf } from '@gitlab/ui'; import { GlSprintf, GlTabs } from '@gitlab/ui';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import OnDemandScans from 'ee/on_demand_scans/components/on_demand_scans.vue'; import OnDemandScans from 'ee/on_demand_scans/components/on_demand_scans.vue';
...@@ -17,6 +17,7 @@ describe('OnDemandScans', () => { ...@@ -17,6 +17,7 @@ describe('OnDemandScans', () => {
// Finders // Finders
const findNewScanLink = () => wrapper.findByTestId('new-scan-link'); const findNewScanLink = () => wrapper.findByTestId('new-scan-link');
const findHelpPageLink = () => wrapper.findByTestId('help-page-link'); const findHelpPageLink = () => wrapper.findByTestId('help-page-link');
const findTabs = () => wrapper.findComponent(GlTabs);
const findAllTab = () => wrapper.findComponent(AllTab); const findAllTab = () => wrapper.findComponent(AllTab);
const findEmptyState = () => wrapper.findComponent(EmptyState); const findEmptyState = () => wrapper.findComponent(EmptyState);
...@@ -32,6 +33,7 @@ describe('OnDemandScans', () => { ...@@ -32,6 +33,7 @@ describe('OnDemandScans', () => {
stubs: { stubs: {
ConfigurationPageLayout, ConfigurationPageLayout,
GlSprintf, GlSprintf,
GlTabs,
}, },
}, },
options, options,
...@@ -81,5 +83,10 @@ describe('OnDemandScans', () => { ...@@ -81,5 +83,10 @@ describe('OnDemandScans', () => {
it('renders the tabs', () => { it('renders the tabs', () => {
expect(findAllTab().exists()).toBe(true); expect(findAllTab().exists()).toBe(true);
}); });
it('sets the initial route to /all', () => {
expect(findTabs().props('value')).toBe(0);
expect(router.currentRoute.path).toBe('/all');
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment