Skip to content

Commit

Permalink
[change] Loader must be shown when validating Token
Browse files Browse the repository at this point in the history
  • Loading branch information
codesankalp committed May 29, 2021
1 parent 678e661 commit 6d44a67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/components/status/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class Status extends React.Component {

async componentDidMount() {
const {cookies, orgSlug, settings, setUserData, logout} = this.props;
const {setLoading} = this.context;
let {userData} = this.props;
this.setState({
rememberMe: localStorage.getItem("rememberMe") === "true",
Expand All @@ -78,14 +79,15 @@ export default class Status extends React.Component {
} catch {
//
}

setLoading(true);
const isValid = await validateToken(
cookies,
orgSlug,
setUserData,
userData,
logout,
);
setLoading(false);
if (isValid) {
const justAuthenticated =
Object.keys(userData).length <= Object.keys(initialState).length;
Expand Down
5 changes: 3 additions & 2 deletions client/components/status/status.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ describe("<Status /> interactions", () => {
is_active: true,
phone_number: "",
};
const setLoading = jest.fn();
wrapper = shallow(<Status {...props} />, {
context: {setLoading: jest.fn()},
context: {setLoading},
});
wrapper.setProps({userData});
await tick();
Expand All @@ -253,7 +254,7 @@ describe("<Status /> interactions", () => {
);
expect(Status.prototype.getUserActiveRadiusSessions).toHaveBeenCalled();
expect(wrapper.instance().state.activeSessions.length).toBe(1);

expect(setLoading.mock.calls.length).toBe(2);
wrapper.setProps({
location: {
search: "",
Expand Down

0 comments on commit 6d44a67

Please sign in to comment.