mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
correct tests and use index resource type
This commit is contained in:
@@ -13,11 +13,12 @@ import {
|
||||
isFetchIndexResourcesPending
|
||||
} from "../modules/indexResource";
|
||||
import PluginLoader from "./PluginLoader";
|
||||
import type { IndexResources } from "@scm-manager/ui-types";
|
||||
|
||||
type Props = {
|
||||
error: Error,
|
||||
loading: boolean,
|
||||
indexResources: any,
|
||||
indexResources: IndexResources,
|
||||
|
||||
// dispatcher functions
|
||||
fetchIndexResources: () => void,
|
||||
@@ -34,7 +35,7 @@ class Index extends Component<Props> {
|
||||
render() {
|
||||
const { indexResources, loading, error, t } = this.props;
|
||||
|
||||
if (error) {
|
||||
if (error) {
|
||||
return (
|
||||
<ErrorPage
|
||||
title={t("app.error.title")}
|
||||
@@ -42,10 +43,9 @@ class Index extends Component<Props> {
|
||||
error={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
else if (loading || !indexResources) {
|
||||
} else if (loading || !indexResources) {
|
||||
return <Loading />;
|
||||
} else {
|
||||
} else {
|
||||
return (
|
||||
<PluginLoader>
|
||||
<App />
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
Image
|
||||
} from "@scm-manager/ui-components";
|
||||
import classNames from "classnames";
|
||||
import { fetchIndexResources, getLoginLink } from "../modules/indexResource";
|
||||
import { getLoginLink } from "../modules/indexResource";
|
||||
|
||||
const styles = {
|
||||
avatar: {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getFailure } from "./failure";
|
||||
import {
|
||||
callFetchIndexResources,
|
||||
FETCH_INDEXRESOURCES_SUCCESS,
|
||||
fetchIndexResources,
|
||||
fetchIndexResources, fetchIndexResourcesPending,
|
||||
fetchIndexResourcesSuccess
|
||||
} from "./indexResource";
|
||||
|
||||
@@ -156,6 +156,7 @@ export const login = (
|
||||
return apiClient
|
||||
.post(loginLink, login_data)
|
||||
.then(response => {
|
||||
dispatch(fetchIndexResourcesPending())
|
||||
return callFetchIndexResources();
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
@@ -97,16 +97,20 @@ describe("auth actions", () => {
|
||||
headers: { "content-type": "application/json" }
|
||||
});
|
||||
|
||||
fetchMock.getOnce("/api/v2/", {
|
||||
_links: {
|
||||
me: {
|
||||
href: "/me"
|
||||
}
|
||||
const meLink = {
|
||||
me: {
|
||||
href: "/me"
|
||||
}
|
||||
};
|
||||
|
||||
fetchMock.getOnce("/api/v2/", {
|
||||
_links: meLink
|
||||
});
|
||||
|
||||
const expectedActions = [
|
||||
{ type: LOGIN_PENDING },
|
||||
{ type: FETCH_INDEXRESOURCES_PENDING },
|
||||
{ type: FETCH_INDEXRESOURCES_SUCCESS, payload: { _links: meLink } },
|
||||
{ type: LOGIN_SUCCESS, payload: me }
|
||||
];
|
||||
|
||||
@@ -208,8 +212,7 @@ describe("auth actions", () => {
|
||||
const expectedActions = [
|
||||
{ type: LOGOUT_PENDING },
|
||||
{ type: LOGOUT_SUCCESS },
|
||||
{ type: FETCH_INDEXRESOURCES_PENDING },
|
||||
{ type: FETCH_INDEXRESOURCES_SUCCESS }
|
||||
{ type: FETCH_INDEXRESOURCES_PENDING }
|
||||
];
|
||||
|
||||
const store = mockStore({});
|
||||
|
||||
Reference in New Issue
Block a user