-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIE-206 app startup - unit tests #5254
Conversation
cdbf54a
to
467df78
Compare
467df78
to
f9fbc04
Compare
f9fbc04
to
a28f6a6
Compare
const userManager: UserManager = new UserManager(getOidcConfig()); | ||
|
||
const url = window.location.href; | ||
const isSilent = window.location.pathname.startsWith('/redirect-from-oauth-silent'); | ||
const url = getCurrentLocation().href; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.location is difficult to mock in unit tests, and it's a global (awkward actor), which makes async unit tests unworkable. So this is being shifted to a thin wrapper that is much easier to mock.
const rootElement = document.getElementById('root'); | ||
const root = createRoot(rootElement!); | ||
root.render(h(RedirectFromOAuth)); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no functional change from old file location in src/auth, but wrapped in callable function.
/** | ||
* gets the current app window url location object | ||
*/ | ||
export const getCurrentLocation = () => window.location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.location is difficult to mock in unit tests, and it's a global (awkward actor), which makes async unit tests unworkable. So this is being shifted to a thin wrapper that is much easier to mock.
close: 'Close', | ||
}, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no functional change from old src/ location, but now in callable wrapper and light ts conversion
- added unit test coverage, made module scope logic into callable (and testable) functions. - shifted startup relatid modules to sub-folder. - light Typescript conversions.
- fixed missing act unit test warning
- minor cleanup
3341420
to
5f6e882
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not test it myself; code looks good. thank you!
Jira Ticket: https://broadworkbench.atlassian.net/browse/[Ticket #]
Summary of changes:
What
Why
Testing strategy