Skip to content

Commit 4e6e9e3

Browse files
committed
PD-5332
1 parent dbe8d43 commit 4e6e9e3

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

src/app/core/wordpress/wordpress.service.spec.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ import { LOCALE_ID } from '@angular/core'
99
describe('WordpressService', () => {
1010
let service: WordpressService
1111
let httpMock: HttpTestingController
12+
let originalRuntimeEnvironment: unknown
1213

13-
const primaryIndexUrl = `${runtimeEnvironment.WORDPRESS_S3}/index.html`
14-
const fallbackIndexUrl = `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/index.html`
14+
const WORDPRESS_S3 = 'https://homepage-qa.orcid.org'
15+
const WORDPRESS_S3_FALLBACK = 'https://homepage-fallback.orcid.org'
16+
const primaryIndexUrl = `${WORDPRESS_S3}/index.html`
17+
const fallbackIndexUrl = `${WORDPRESS_S3_FALLBACK}/index.html`
1518

1619
beforeEach(() => {
20+
originalRuntimeEnvironment = (globalThis as any).runtimeEnvironment
21+
;(globalThis as any).runtimeEnvironment = {
22+
...(originalRuntimeEnvironment as Record<string, unknown> | undefined),
23+
WORDPRESS_S3,
24+
WORDPRESS_S3_FALLBACK,
25+
}
26+
1727
TestBed.configureTestingModule({
1828
imports: [HttpClientTestingModule],
1929
providers: [{ provide: LOCALE_ID, useValue: 'en' }],
@@ -24,6 +34,7 @@ describe('WordpressService', () => {
2434

2535
afterEach(() => {
2636
httpMock.verify()
37+
;(globalThis as any).runtimeEnvironment = originalRuntimeEnvironment
2738
})
2839

2940
it('should be created', () => {
@@ -35,7 +46,7 @@ describe('WordpressService', () => {
3546
'<html><head></head><body><img src="./assets/image.png"></body></html>'
3647

3748
service.getHomePagePost().subscribe((html) => {
38-
expect(html).toContain(`${runtimeEnvironment.WORDPRESS_S3}/assets/image.png`)
49+
expect(html).toContain(`${WORDPRESS_S3}/assets/image.png`)
3950
})
4051

4152
const req = httpMock.expectOne(primaryIndexUrl)
@@ -64,13 +75,13 @@ describe('WordpressService', () => {
6475
const mockCss = '.hero{background:url("assets/bg.png")}'
6576

6677
service.getHomePageCSS().subscribe((css) => {
67-
expect(css).toContain(`${runtimeEnvironment.WORDPRESS_S3}/assets/bg.png`)
78+
expect(css).toContain(`${WORDPRESS_S3}/assets/bg.png`)
6879
})
6980

7081
const indexReq = httpMock.expectOne(primaryIndexUrl)
7182
indexReq.flush(mockIndex)
7283
const cssReq = httpMock.expectOne(
73-
`${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage-d4235c1c61.css`
84+
`${WORDPRESS_S3}/wordpress-homepage-d4235c1c61.css`
7485
)
7586
cssReq.flush(mockCss)
7687
})
@@ -86,7 +97,7 @@ describe('WordpressService', () => {
8697
const indexReq = httpMock.expectOne(primaryIndexUrl)
8798
indexReq.flush(mockIndex)
8899
const cssReq = httpMock.expectOne(
89-
`${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.css`
100+
`${WORDPRESS_S3}/wordpress-homepage.css`
90101
)
91102
cssReq.flush(mockCss)
92103
})
@@ -98,14 +109,14 @@ describe('WordpressService', () => {
98109

99110
service.getHomePageJS().subscribe((js) => {
100111
expect(js).toContain(
101-
`const image = "${runtimeEnvironment.WORDPRESS_S3}/assets/test.png"`
112+
`const image = "${WORDPRESS_S3}/assets/test.png"`
102113
)
103114
})
104115

105116
const indexReq = httpMock.expectOne(primaryIndexUrl)
106117
indexReq.flush(mockIndex)
107118
const jsReq = httpMock.expectOne(
108-
`${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage-64bd37a0a7.js`
119+
`${WORDPRESS_S3}/wordpress-homepage-64bd37a0a7.js`
109120
)
110121
jsReq.flush(mockJs)
111122
})
@@ -117,14 +128,14 @@ describe('WordpressService', () => {
117128

118129
service.getHomePageModulesJS().subscribe((js) => {
119130
expect(js).toContain(
120-
`const icon = "${runtimeEnvironment.WORDPRESS_S3}/assets/icon.svg"`
131+
`const icon = "${WORDPRESS_S3}/assets/icon.svg"`
121132
)
122133
})
123134

124135
const indexReq = httpMock.expectOne(primaryIndexUrl)
125136
indexReq.flush(mockIndex)
126137
const jsReq = httpMock.expectOne(
127-
`${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage-modules-34238353bb.js`
138+
`${WORDPRESS_S3}/wordpress-homepage-modules-34238353bb.js`
128139
)
129140
jsReq.flush(mockJs)
130141
})

0 commit comments

Comments
 (0)