Skip to content

Commit

Permalink
fix: Adjust tests for missing global variables (mock them)
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Apr 21, 2024
1 parent 0ec6471 commit 4408520
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions tests/loadTranslations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ const setLocale = (locale) => document.documentElement.setAttribute('data-locale
describe('loadTranslations', () => {
let server: MockXhrServer

beforeAll(() => {
// Mock some server state
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any)._oc_webroot = '';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any)._oc_appswebroots = {
404: '/404',
500: '/500',
empty: '/empty',
invalid: '/invalid',
'missing-bundle': '/missing-bundle',
myapp: '/myapp',
networkissue: '/networkissue',
}
})

beforeEach(() => {
setLocale('de')
server = newServer()
Expand Down
3 changes: 2 additions & 1 deletion tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
// Allow us to pass js files to ts-jest without babel
"allowJs": true,
},
"include": ["./**/*.ts"],
"include": ["./**.ts"],
"exclude": []
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"module": "ES2020",
"declaration": true,
"esModuleInterop": true,
"moduleResolution": "node",
"moduleResolution": "Bundler",
"noImplicitAny": false,
"outDir": "./dist",
"strict": true,
Expand Down

0 comments on commit 4408520

Please sign in to comment.