Skip to content
This repository was archived by the owner on Jun 29, 2021. It is now read-only.

Commit 651fbc0

Browse files
committed
Fix tests to use defaultContext
1 parent cabfa9d commit 651fbc0

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

test/utils.test.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,54 @@
11
import { Layout } from '../src/types'
22
import { defaultContext, getNavWidth, getScreenValue } from '../src/utils'
33

4-
const initialContext = defaultContext()
5-
64
describe('getNavWidth', () => {
75
describe('variant permanent', () => {
86
let config: Omit<Layout, 'currentNavWidth'>
97

108
beforeEach(() => {
11-
config = Object.assign({}, initialContext, {
9+
config = Object.assign({}, defaultContext, {
1210
navVariant: 'permanent',
1311
})
1412
})
1513

1614
it('returns navWidth when not collapsed and open', () => {
1715
config.collapsed = false
1816
config.open = true
19-
expect(getNavWidth(config)).toBe(initialContext.navWidth)
17+
expect(getNavWidth(config)).toBe(defaultContext.navWidth)
2018
})
2119

2220
it('returns navWidth when not collapsed and closed', () => {
2321
config.collapsed = false
2422
config.open = false
25-
expect(getNavWidth(config)).toBe(initialContext.navWidth)
23+
expect(getNavWidth(config)).toBe(defaultContext.navWidth)
2624
})
2725

2826
it('returns collapsedWidth when collapsed and open', () => {
2927
config.collapsed = true
3028
config.open = true
31-
expect(getNavWidth(config)).toBe(initialContext.collapsedWidth)
29+
expect(getNavWidth(config)).toBe(defaultContext.collapsedWidth)
3230
})
3331

3432
it('returns collapsedWidth when collapsed and closed', () => {
3533
config.collapsed = true
3634
config.open = false
37-
expect(getNavWidth(config)).toBe(initialContext.collapsedWidth)
35+
expect(getNavWidth(config)).toBe(defaultContext.collapsedWidth)
3836
})
3937
})
4038

4139
describe('variant persistent', () => {
4240
let config: Omit<Layout, 'currentNavWidth'>
4341

4442
beforeEach(() => {
45-
config = Object.assign({}, initialContext, {
43+
config = Object.assign({}, defaultContext, {
4644
navVariant: 'persistent',
4745
})
4846
})
4947

5048
it('returns navWidth when not collapsed and open', () => {
5149
config.collapsed = false
5250
config.open = true
53-
expect(getNavWidth(config)).toBe(initialContext.navWidth)
51+
expect(getNavWidth(config)).toBe(defaultContext.navWidth)
5452
})
5553

5654
it('returns 0 when not collapsed and closed', () => {
@@ -62,7 +60,7 @@ describe('getNavWidth', () => {
6260
it('returns collapsedWidth when collapsed and open', () => {
6361
config.collapsed = true
6462
config.open = true
65-
expect(getNavWidth(config)).toBe(initialContext.collapsedWidth)
63+
expect(getNavWidth(config)).toBe(defaultContext.collapsedWidth)
6664
})
6765

6866
it('returns 0 when collapsed and closed', () => {
@@ -76,15 +74,15 @@ describe('getNavWidth', () => {
7674
let config: Omit<Layout, 'currentNavWidth'>
7775

7876
beforeEach(() => {
79-
config = Object.assign({}, initialContext, {
77+
config = Object.assign({}, defaultContext, {
8078
navVariant: 'temporary',
8179
})
8280
})
8381

8482
it('returns navWidth when not collapsed and open', () => {
8583
config.collapsed = false
8684
config.open = true
87-
expect(getNavWidth(config)).toBe(initialContext.navWidth)
85+
expect(getNavWidth(config)).toBe(defaultContext.navWidth)
8886
})
8987

9088
it('returns 0 when not collapsed and closed', () => {
@@ -96,7 +94,7 @@ describe('getNavWidth', () => {
9694
it('returns collapsedWidth when collapsed and open', () => {
9795
config.collapsed = true
9896
config.open = true
99-
expect(getNavWidth(config)).toBe(initialContext.collapsedWidth)
97+
expect(getNavWidth(config)).toBe(defaultContext.collapsedWidth)
10098
})
10199

102100
it('returns 0 when collapsed and closed', () => {

0 commit comments

Comments
 (0)