-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add usedMainNavigation in NavigationSliceZone to choose between pix-p…
…ro or pix-site nav
- Loading branch information
1 parent
54c8453
commit 45b62b6
Showing
2 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
import { shallowMount } from '@vue/test-utils' | ||
import NavigationSliceZone from '~/components/NavigationSliceZone' | ||
|
||
jest.mock('~/services/document-fetcher') | ||
|
||
describe('NavigationSliceZone slice', () => { | ||
let component | ||
let store | ||
|
||
const expectedSiteNavigation = { | ||
data: { | ||
navigation_for: 'pix-site', | ||
body: [ | ||
{ | ||
slice_type: 'logos_zone', | ||
slice_label: null, | ||
items: [], | ||
primary: {}, | ||
}, | ||
{ | ||
slice_type: 'navigation_zone', | ||
items: [], | ||
primary: {}, | ||
}, | ||
{ | ||
slice_type: 'actions_zone', | ||
slice_label: null, | ||
items: [], | ||
primary: {}, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
const expectedProNavigation = { | ||
data: { | ||
navigation_for: 'pix-pro', | ||
body: [ | ||
{ | ||
slice_type: 'logos_zone', | ||
slice_label: null, | ||
items: [], | ||
primary: {}, | ||
}, | ||
{ | ||
slice_type: 'navigation_zone', | ||
items: [], | ||
primary: {}, | ||
}, | ||
{ | ||
slice_type: 'actions_zone', | ||
slice_label: null, | ||
items: [], | ||
primary: {}, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
describe('Slice: NavigationSliceZone', () => { | ||
afterEach(() => { | ||
process.env = { | ||
isPixPro: false, | ||
} | ||
}) | ||
|
||
describe('When we are in pix-site and we have two navigation', () => { | ||
beforeEach(() => { | ||
store = { | ||
state: { | ||
mainNavigation: [expectedSiteNavigation, expectedProNavigation], | ||
}, | ||
} | ||
}) | ||
|
||
it('should return the site navigation', () => { | ||
// given | ||
component = shallowMount(NavigationSliceZone, { | ||
mocks: { | ||
$store: store, | ||
}, | ||
stubs: { | ||
'client-only': true, | ||
'push-menu': true, | ||
'burger-menu-nav': true, | ||
'organization-nav': true, | ||
'logos-zone': true, | ||
'navigation-zone': true, | ||
'actions-zone': true, | ||
'pix-pro-sub-nav': true, | ||
fa: true, | ||
}, | ||
}) | ||
|
||
// when | ||
const result = component.vm.usedMainNavigation | ||
|
||
// then | ||
expect(result).toEqual(expectedSiteNavigation) | ||
}) | ||
}) | ||
|
||
describe('When we are in pix-pro and we have two navigation', () => { | ||
beforeEach(() => { | ||
process.env = { | ||
isPixPro: true, | ||
} | ||
store = { | ||
state: { | ||
mainNavigation: [expectedSiteNavigation, expectedProNavigation], | ||
}, | ||
} | ||
}) | ||
|
||
it('should return the pro navigation', () => { | ||
// given | ||
component = shallowMount(NavigationSliceZone, { | ||
mocks: { | ||
$store: store, | ||
}, | ||
stubs: { | ||
'client-only': true, | ||
'push-menu': true, | ||
'burger-menu-nav': true, | ||
'organization-nav': true, | ||
'logos-zone': true, | ||
'navigation-zone': true, | ||
'actions-zone': true, | ||
'pix-pro-sub-nav': true, | ||
fa: true, | ||
}, | ||
}) | ||
|
||
// when | ||
const result = component.vm.usedMainNavigation | ||
|
||
// then | ||
expect(result).toEqual(expectedProNavigation) | ||
}) | ||
}) | ||
|
||
describe('When we are in pix-pro and we have only the site navigation', () => { | ||
beforeEach(() => { | ||
process.env = { | ||
isPixPro: true, | ||
} | ||
store = { | ||
state: { | ||
mainNavigation: [expectedSiteNavigation], | ||
}, | ||
} | ||
}) | ||
|
||
it('should return the site navigation', () => { | ||
// given | ||
component = shallowMount(NavigationSliceZone, { | ||
mocks: { | ||
$store: store, | ||
}, | ||
stubs: { | ||
'client-only': true, | ||
'push-menu': true, | ||
'burger-menu-nav': true, | ||
'organization-nav': true, | ||
'logos-zone': true, | ||
'navigation-zone': true, | ||
'actions-zone': true, | ||
'pix-pro-sub-nav': true, | ||
fa: true, | ||
}, | ||
}) | ||
|
||
// when | ||
const result = component.vm.usedMainNavigation | ||
|
||
// then | ||
expect(result).toEqual(expectedSiteNavigation) | ||
}) | ||
}) | ||
}) | ||
}) |