@@ -5,7 +5,7 @@ import defaultState from '@/store/default-state'
5
5
import buildGetters from '@/store/getters'
6
6
import buildMutations from '@/store/mutations'
7
7
import MockedServices from '@/spec/__mocks__/services'
8
- import { page , normalizedPage } from '@/spec/__mocks__/page'
8
+ import { page } from '@/spec/__mocks__/page'
9
9
import { sectionsContent , normalizedSectionsContent } from '@/spec/__mocks__/sections-content'
10
10
import { site } from '@/spec/__mocks__/site'
11
11
import { theme } from '@/spec/__mocks__/theme'
@@ -31,11 +31,11 @@ describe('Getters', () => {
31
31
} )
32
32
33
33
describe ( '#currentPagePath' , ( ) => {
34
- let freshNormalizedPage = null
35
- beforeEach ( ( ) => {
36
- freshNormalizedPage = structuredClone ( normalizedPage )
37
- mockedServices . page . normalize = vi . fn ( ( ) => freshNormalizedPage )
38
- } )
34
+ // let freshNormalizedPage = null
35
+ // beforeEach(() => {
36
+ // freshNormalizedPage = structuredClone(normalizedPage)
37
+ // mockedServices.page.normalize = vi.fn(() => freshNormalizedPage)
38
+ // })
39
39
describe ( 'Given this is the home page' , ( ) => {
40
40
it ( 'returns the path of the page' , ( ) => {
41
41
store . commit ( 'SET_PAGE' , page )
@@ -44,39 +44,38 @@ describe('Getters', () => {
44
44
} )
45
45
describe ( 'Given this is a random page' , ( ) => {
46
46
it ( 'returns the path of the page' , ( ) => {
47
- freshNormalizedPage . entities . page [ '1' ] . path = '/bonjour'
48
- freshNormalizedPage . entities . page [ '1' ] . liveUrl = '/fr/bonjour'
49
- store . commit ( 'SET_PAGE' , page )
47
+ const freshPage = structuredClone ( page )
48
+ freshPage . path = '/bonjour'
49
+ freshPage . liveUrl = '/fr/bonjour'
50
+ store . commit ( 'SET_PAGE' , freshPage )
50
51
expect ( store . getters . currentPagePath ) . toStrictEqual ( '/fr/bonjour' )
51
52
} )
52
53
} )
53
54
describe ( 'Given the liveUrl contains the domain name' , ( ) => {
54
55
it ( 'returns the path of the page' , ( ) => {
55
- freshNormalizedPage . entities . page [ '1' ] . liveUrl = 'https://example.com:8080/fr'
56
- freshNormalizedPage . entities . page [ '1' ] . path = 'index'
57
- store . commit ( 'SET_PAGE' , page )
56
+ const freshPage = structuredClone ( page )
57
+ freshPage . liveUrl = 'https://example.com:8080/fr'
58
+ freshPage . path = 'index'
59
+ store . commit ( 'SET_PAGE' , freshPage )
58
60
expect ( store . getters . currentPagePath ) . toStrictEqual ( '/fr/index' )
59
61
} )
60
62
} )
61
63
} )
62
64
63
65
describe ( '#currentPageUrl' , ( ) => {
64
- let freshNormalizedPage = null
65
- beforeEach ( ( ) => {
66
- freshNormalizedPage = structuredClone ( normalizedPage )
67
- mockedServices . page . normalize = vi . fn ( ( ) => freshNormalizedPage )
68
- } )
69
66
describe ( 'Given the page live URL is not prefixed with the base URL' , ( ) => {
70
67
it ( 'returns the url of the page' , ( ) => {
71
- freshNormalizedPage . entities . page [ '1' ] . liveUrl = '/hello-world'
72
- store . commit ( 'SET_PAGE' , page )
68
+ const freshPage = structuredClone ( page )
69
+ freshPage . liveUrl = '/hello-world'
70
+ store . commit ( 'SET_PAGE' , freshPage )
73
71
expect ( store . getters . currentPageUrl ) . toStrictEqual ( 'http://localhost:3000/hello-world' )
74
72
} )
75
73
} )
76
74
describe ( 'Given the page live URL is prefixed with the base URL' , ( ) => {
77
75
it ( 'returns the url of the page' , ( ) => {
78
- freshNormalizedPage . entities . page [ '1' ] . liveUrl = 'https://example.com:8080/fr'
79
- store . commit ( 'SET_PAGE' , page )
76
+ const freshPage = structuredClone ( page )
77
+ freshPage . liveUrl = 'https://example.com:8080/fr'
78
+ store . commit ( 'SET_PAGE' , freshPage )
80
79
expect ( store . getters . currentPageUrl ) . toStrictEqual ( 'https://example.com:8080/fr' )
81
80
} )
82
81
} )
0 commit comments