mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
fix tests
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { apiClient } from "@scm-manager/ui-components";
|
|
||||||
import { getSources } from "../modules/sources";
|
import { getSources } from "../modules/sources";
|
||||||
import type { Repository, File } from "@scm-manager/ui-types";
|
import type { Repository, File } from "@scm-manager/ui-types";
|
||||||
import {
|
import {
|
||||||
@@ -17,19 +16,17 @@ import FileSize from "../components/FileSize";
|
|||||||
import injectSheet from "react-jss";
|
import injectSheet from "react-jss";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||||
|
import { getContentType } from "./contentType";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string,
|
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
error: Error,
|
error: Error,
|
||||||
file: File,
|
file: File,
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
revision: string,
|
revision: string,
|
||||||
path: string,
|
path: string,
|
||||||
// context props
|
|
||||||
classes: any,
|
classes: any,
|
||||||
t: string => string,
|
t: string => string
|
||||||
match: any
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@@ -210,19 +207,6 @@ class Content extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getContentType(url: string, state: any) {
|
|
||||||
return apiClient
|
|
||||||
.head(url)
|
|
||||||
.then(response => {
|
|
||||||
return {
|
|
||||||
type: response.headers.get("Content-Type"),
|
|
||||||
language: response.headers.get("X-Programming-Language")
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
return { error: err };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = (state: any, ownProps: Props) => {
|
const mapStateToProps = (state: any, ownProps: Props) => {
|
||||||
const { repository, revision, path } = ownProps;
|
const { repository, revision, path } = ownProps;
|
||||||
|
|||||||
16
scm-ui/src/repos/sources/containers/contentType.js
Normal file
16
scm-ui/src/repos/sources/containers/contentType.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//@flow
|
||||||
|
import { apiClient } from "@scm-manager/ui-components";
|
||||||
|
|
||||||
|
export function getContentType(url: string) {
|
||||||
|
return apiClient
|
||||||
|
.head(url)
|
||||||
|
.then(response => {
|
||||||
|
return {
|
||||||
|
type: response.headers.get("Content-Type"),
|
||||||
|
language: response.headers.get("X-Programming-Language")
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
return { error: err };
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import fetchMock from "fetch-mock";
|
import fetchMock from "fetch-mock";
|
||||||
import { getContentType } from "./Content";
|
import { getContentType } from "./contentType";
|
||||||
|
|
||||||
describe("get content type", () => {
|
describe("get content type", () => {
|
||||||
const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent";
|
const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent";
|
||||||
Reference in New Issue
Block a user