mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Simplify test data
This commit is contained in:
@@ -31,77 +31,17 @@ const HUNK_0 = {
|
||||
oldLines: 8,
|
||||
newLines: 8,
|
||||
changes: [
|
||||
{
|
||||
content: "// @flow",
|
||||
type: "normal",
|
||||
oldLineNumber: 1,
|
||||
newLineNumber: 1,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: 'import React from "react";',
|
||||
type: "normal",
|
||||
oldLineNumber: 2,
|
||||
newLineNumber: 2,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: 'import { translate } from "react-i18next";',
|
||||
type: "delete",
|
||||
lineNumber: 3,
|
||||
isDelete: true
|
||||
},
|
||||
{
|
||||
content: 'import { Textarea } from "@scm-manager/ui-components";',
|
||||
type: "delete",
|
||||
lineNumber: 4,
|
||||
isDelete: true
|
||||
},
|
||||
{
|
||||
content: 'import type { Me } from "@scm-manager/ui-types";',
|
||||
type: "delete",
|
||||
lineNumber: 5,
|
||||
isDelete: true
|
||||
},
|
||||
{
|
||||
content: 'import {translate} from "react-i18next";',
|
||||
type: "insert",
|
||||
lineNumber: 3,
|
||||
isInsert: true
|
||||
},
|
||||
{
|
||||
content: 'import {Textarea} from "@scm-manager/ui-components";',
|
||||
type: "insert",
|
||||
lineNumber: 4,
|
||||
isInsert: true
|
||||
},
|
||||
{
|
||||
content: 'import type {Me} from "@scm-manager/ui-types";',
|
||||
type: "insert",
|
||||
lineNumber: 5,
|
||||
isInsert: true
|
||||
},
|
||||
{
|
||||
content: 'import injectSheet from "react-jss";',
|
||||
type: "normal",
|
||||
oldLineNumber: 6,
|
||||
newLineNumber: 6,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: "",
|
||||
type: "normal",
|
||||
oldLineNumber: 7,
|
||||
newLineNumber: 7,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: "const styles = {",
|
||||
type: "normal",
|
||||
oldLineNumber: 8,
|
||||
newLineNumber: 8,
|
||||
isNormal: true
|
||||
}
|
||||
{ content: "line", type: "normal", oldLineNumber: 1, newLineNumber: 1, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 2, newLineNumber: 2, isNormal: true },
|
||||
{ content: "line", type: "delete", lineNumber: 3, isDelete: true },
|
||||
{ content: "line", type: "delete", lineNumber: 4, isDelete: true },
|
||||
{ content: "line", type: "delete", lineNumber: 5, isDelete: true },
|
||||
{ content: "line", type: "insert", lineNumber: 3, isInsert: true },
|
||||
{ content: "line", type: "insert", lineNumber: 4, isInsert: true },
|
||||
{ content: "line", type: "insert", lineNumber: 5, isInsert: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 6, newLineNumber: 6, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 7, newLineNumber: 7, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 8, newLineNumber: 8, isNormal: true }
|
||||
]
|
||||
};
|
||||
const HUNK_1 = {
|
||||
@@ -111,54 +51,13 @@ const HUNK_1 = {
|
||||
oldLines: 6,
|
||||
newLines: 7,
|
||||
changes: [
|
||||
{
|
||||
content: "type Props = {",
|
||||
type: "normal",
|
||||
oldLineNumber: 14,
|
||||
newLineNumber: 14,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " me: Me,",
|
||||
type: "normal",
|
||||
oldLineNumber: 15,
|
||||
newLineNumber: 15,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " onChange: string => void,",
|
||||
type: "normal",
|
||||
oldLineNumber: 16,
|
||||
newLineNumber: 16,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " disabled: boolean,",
|
||||
type: "insert",
|
||||
lineNumber: 17,
|
||||
isInsert: true
|
||||
},
|
||||
{
|
||||
content: " //context props",
|
||||
type: "normal",
|
||||
oldLineNumber: 17,
|
||||
newLineNumber: 18,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " t: string => string,",
|
||||
type: "normal",
|
||||
oldLineNumber: 18,
|
||||
newLineNumber: 19,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " classes: any",
|
||||
type: "normal",
|
||||
oldLineNumber: 19,
|
||||
newLineNumber: 20,
|
||||
isNormal: true
|
||||
}
|
||||
{ content: "line", type: "normal", oldLineNumber: 14, newLineNumber: 14, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 15, newLineNumber: 15, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 16, newLineNumber: 16, isNormal: true },
|
||||
{ content: "line", type: "insert", lineNumber: 17, isInsert: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 17, newLineNumber: 18, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 18, newLineNumber: 19, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 19, newLineNumber: 20, isNormal: true }
|
||||
]
|
||||
};
|
||||
const HUNK_2 = {
|
||||
@@ -168,60 +67,14 @@ const HUNK_2 = {
|
||||
oldLines: 7,
|
||||
newLines: 7,
|
||||
changes: [
|
||||
{
|
||||
content: "",
|
||||
type: "normal",
|
||||
oldLineNumber: 21,
|
||||
newLineNumber: 22,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: "class CommitMessage extends React.Component<Props> {",
|
||||
type: "normal",
|
||||
oldLineNumber: 22,
|
||||
newLineNumber: 23,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " render() {",
|
||||
type: "normal",
|
||||
oldLineNumber: 23,
|
||||
newLineNumber: 24,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " const { t, classes, me, onChange } = this.props;",
|
||||
type: "delete",
|
||||
lineNumber: 24,
|
||||
isDelete: true
|
||||
},
|
||||
{
|
||||
content: " const {t, classes, me, onChange, disabled} = this.props;",
|
||||
type: "insert",
|
||||
lineNumber: 25,
|
||||
isInsert: true
|
||||
},
|
||||
{
|
||||
content: " return (",
|
||||
type: "normal",
|
||||
oldLineNumber: 25,
|
||||
newLineNumber: 26,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " <>",
|
||||
type: "normal",
|
||||
oldLineNumber: 26,
|
||||
newLineNumber: 27,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " <div className={classes.marginBottom}>",
|
||||
type: "normal",
|
||||
oldLineNumber: 27,
|
||||
newLineNumber: 28,
|
||||
isNormal: true
|
||||
}
|
||||
{ content: "line", type: "normal", oldLineNumber: 21, newLineNumber: 22, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 22, newLineNumber: 23, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 23, newLineNumber: 24, isNormal: true },
|
||||
{ content: "line", type: "delete", lineNumber: 24, isDelete: true },
|
||||
{ content: "line", type: "insert", lineNumber: 25, isInsert: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 25, newLineNumber: 26, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 26, newLineNumber: 27, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 27, newLineNumber: 28, isNormal: true }
|
||||
]
|
||||
};
|
||||
const HUNK_3 = {
|
||||
@@ -231,54 +84,13 @@ const HUNK_3 = {
|
||||
oldLines: 6,
|
||||
newLines: 7,
|
||||
changes: [
|
||||
{
|
||||
content: " <Textarea",
|
||||
type: "normal",
|
||||
oldLineNumber: 33,
|
||||
newLineNumber: 34,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: ' placeholder={t("scm-editor-plugin.commit.placeholder")}',
|
||||
type: "normal",
|
||||
oldLineNumber: 34,
|
||||
newLineNumber: 35,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " onChange={message => onChange(message)}",
|
||||
type: "normal",
|
||||
oldLineNumber: 35,
|
||||
newLineNumber: 36,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " disabled={disabled}",
|
||||
type: "insert",
|
||||
lineNumber: 37,
|
||||
isInsert: true
|
||||
},
|
||||
{
|
||||
content: " />",
|
||||
type: "normal",
|
||||
oldLineNumber: 36,
|
||||
newLineNumber: 38,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " </>",
|
||||
type: "normal",
|
||||
oldLineNumber: 37,
|
||||
newLineNumber: 39,
|
||||
isNormal: true
|
||||
},
|
||||
{
|
||||
content: " );",
|
||||
type: "normal",
|
||||
oldLineNumber: 38,
|
||||
newLineNumber: 40,
|
||||
isNormal: true
|
||||
}
|
||||
{ content: "line", type: "normal", oldLineNumber: 33, newLineNumber: 34, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 34, newLineNumber: 35, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 35, newLineNumber: 36, isNormal: true },
|
||||
{ content: "line", type: "insert", lineNumber: 37, isInsert: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 36, newLineNumber: 38, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 37, newLineNumber: 39, isNormal: true },
|
||||
{ content: "line", type: "normal", oldLineNumber: 38, newLineNumber: 40, isNormal: true }
|
||||
]
|
||||
};
|
||||
const TEST_CONTENT_WITH_HUNKS = {
|
||||
@@ -293,8 +105,7 @@ const TEST_CONTENT_WITH_HUNKS = {
|
||||
hunks: [HUNK_0, HUNK_1, HUNK_2, HUNK_3],
|
||||
_links: {
|
||||
lines: {
|
||||
href:
|
||||
"http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start={start}&end={end}",
|
||||
href: "http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start={start}&end={end}",
|
||||
templated: true
|
||||
}
|
||||
}
|
||||
@@ -392,7 +203,10 @@ describe("with hunks the diff expander", () => {
|
||||
});
|
||||
it("should expand hunk with new line from api client at the bottom", async () => {
|
||||
expect(diffExpander.getHunk(1).hunk.changes.length).toBe(7);
|
||||
fetchMock.get("http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=22&end=22", "new line 1\nnew line 2");
|
||||
fetchMock.get(
|
||||
"http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=22&end=22",
|
||||
"new line 1\nnew line 2"
|
||||
);
|
||||
let newFile;
|
||||
diffExpander.getHunk(1).expandBottom(file => {
|
||||
newFile = file;
|
||||
@@ -405,7 +219,10 @@ describe("with hunks the diff expander", () => {
|
||||
});
|
||||
it("should expand hunk with new line from api client at the top", async () => {
|
||||
expect(diffExpander.getHunk(1).hunk.changes.length).toBe(7);
|
||||
fetchMock.get("http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=9&end=13", "new line 1\nnew line 2");
|
||||
fetchMock.get(
|
||||
"http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=9&end=13",
|
||||
"new line 1\nnew line 2"
|
||||
);
|
||||
let newFile;
|
||||
diffExpander.getHunk(1).expandHead(file => {
|
||||
newFile = file;
|
||||
|
||||
Reference in New Issue
Block a user