refactor: Use lambda functions for map instead of anonymous functions
This commit is contained in:
parent
7b1727dc74
commit
ef1ccb093e
2 changed files with 26 additions and 26 deletions
|
|
@ -429,7 +429,7 @@ describe("DiffParser", () => {
|
|||
expect(file1.newName).toEqual("sample.js");
|
||||
expect(file1.blocks.length).toEqual(1);
|
||||
|
||||
const linesContent = file1.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file1.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect(["-test", "+test1r", "+test2r"]).toEqual(linesContent);
|
||||
|
|
@ -449,7 +449,7 @@ describe("DiffParser", () => {
|
|||
expect(file1.newName).toEqual("sample.js");
|
||||
expect(file1.blocks.length).toEqual(1);
|
||||
|
||||
const linesContent = file1.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file1.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect(["-test", "+test1r", "+test2r"]).toEqual(linesContent);
|
||||
|
|
@ -478,12 +478,12 @@ describe("DiffParser", () => {
|
|||
expect(file1.newName).toEqual("sample.js");
|
||||
expect(file1.blocks.length).toEqual(2);
|
||||
|
||||
const linesContent1 = file1.blocks[0].lines.map(function(line) {
|
||||
const linesContent1 = file1.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect(["-test"]).toEqual(linesContent1);
|
||||
|
||||
const linesContent2 = file1.blocks[1].lines.map(function(line) {
|
||||
const linesContent2 = file1.blocks[1].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect(["+test"]).toEqual(linesContent2);
|
||||
|
|
@ -495,7 +495,7 @@ describe("DiffParser", () => {
|
|||
expect(file2.newName).toEqual("sample1.js");
|
||||
expect(file2.blocks.length).toEqual(1);
|
||||
|
||||
const linesContent = file2.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file2.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect(["+test1"]).toEqual(linesContent);
|
||||
|
|
@ -525,7 +525,7 @@ describe("DiffParser", () => {
|
|||
expect(file1.newName).toEqual("sample.js");
|
||||
expect(file1.blocks.length).toEqual(1);
|
||||
|
||||
const linesContent = file1.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file1.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect([" test", " ", "-- 1", "--- 1", "---- 1", " ", "++ 2", "+++ 2", "++++ 2"]).toEqual(linesContent);
|
||||
|
|
@ -543,7 +543,7 @@ describe("DiffParser", () => {
|
|||
expect(file1.newName).toEqual("sample.js");
|
||||
expect(file1.blocks.length).toEqual(1);
|
||||
|
||||
const linesContent = file1.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file1.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect([" test"]).toEqual(linesContent);
|
||||
|
|
@ -594,7 +594,7 @@ describe("DiffParser", () => {
|
|||
expect(file1.newName).toEqual("src/test-baz.js");
|
||||
expect(file1.blocks.length).toEqual(1);
|
||||
expect(file1.blocks[0].lines.length).toEqual(5);
|
||||
const linesContent = file1.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file1.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect([" function foo() {", '-var bar = "Whoops!";', '+var baz = "Whoops!";', " }", " "]).toEqual(linesContent);
|
||||
|
|
@ -667,7 +667,7 @@ describe("DiffParser", () => {
|
|||
expect(file3.newName).toEqual("src/test-baz.js");
|
||||
expect(file3.blocks.length).toEqual(1);
|
||||
expect(file3.blocks[0].lines.length).toEqual(5);
|
||||
const linesContent = file3.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file3.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect([" function foo() {", '-var bar = "Whoops!";', '+var baz = "Whoops!";', " }", " "]).toEqual(linesContent);
|
||||
|
|
@ -723,7 +723,7 @@ describe("DiffParser", () => {
|
|||
expect(file2.newName).toEqual("src/test-baz.js");
|
||||
expect(file2.blocks.length).toEqual(1);
|
||||
expect(file2.blocks[0].lines.length).toEqual(5);
|
||||
const linesContent = file2.blocks[0].lines.map(function(line) {
|
||||
const linesContent = file2.blocks[0].lines.map(line => {
|
||||
return line.content;
|
||||
});
|
||||
expect([" function foo() {", '-var bar = "Whoops!";', '+var baz = "Whoops!";', " }", " "]).toEqual(linesContent);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import * as renderUtils from "../render-utils";
|
||||
import { DiffStyleType, LineMatchingType } from "../types";
|
||||
|
||||
describe("Utils", function() {
|
||||
describe("getHtmlId", function() {
|
||||
it("should generate file unique id", function() {
|
||||
describe("Utils", () => {
|
||||
describe("getHtmlId", () => {
|
||||
it("should generate file unique id", () => {
|
||||
const result = renderUtils.getHtmlId({
|
||||
oldName: "sample.js",
|
||||
newName: "sample.js"
|
||||
});
|
||||
expect("d2h-960013").toEqual(result);
|
||||
});
|
||||
it("should generate file unique id for empty hashes", function() {
|
||||
it("should generate file unique id for empty hashes", () => {
|
||||
const result = renderUtils.getHtmlId({
|
||||
oldName: "sample.js",
|
||||
newName: "sample.js"
|
||||
|
|
@ -19,50 +19,50 @@ describe("Utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getDiffName", function() {
|
||||
it("should generate the file name for a changed file", function() {
|
||||
describe("getDiffName", () => {
|
||||
it("should generate the file name for a changed file", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "sample.js",
|
||||
newName: "sample.js"
|
||||
});
|
||||
expect("sample.js").toEqual(result);
|
||||
});
|
||||
it("should generate the file name for a changed file and full rename", function() {
|
||||
it("should generate the file name for a changed file and full rename", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "sample1.js",
|
||||
newName: "sample2.js"
|
||||
});
|
||||
expect("sample1.js → sample2.js").toEqual(result);
|
||||
});
|
||||
it("should generate the file name for a changed file and prefix rename", function() {
|
||||
it("should generate the file name for a changed file and prefix rename", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "src/path/sample.js",
|
||||
newName: "source/path/sample.js"
|
||||
});
|
||||
expect("{src → source}/path/sample.js").toEqual(result);
|
||||
});
|
||||
it("should generate the file name for a changed file and suffix rename", function() {
|
||||
it("should generate the file name for a changed file and suffix rename", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "src/path/sample1.js",
|
||||
newName: "src/path/sample2.js"
|
||||
});
|
||||
expect("src/path/{sample1.js → sample2.js}").toEqual(result);
|
||||
});
|
||||
it("should generate the file name for a changed file and middle rename", function() {
|
||||
it("should generate the file name for a changed file and middle rename", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "src/really/big/path/sample.js",
|
||||
newName: "src/small/path/sample.js"
|
||||
});
|
||||
expect("src/{really/big → small}/path/sample.js").toEqual(result);
|
||||
});
|
||||
it("should generate the file name for a deleted file", function() {
|
||||
it("should generate the file name for a deleted file", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "src/my/file.js",
|
||||
newName: "/dev/null"
|
||||
});
|
||||
expect("src/my/file.js").toEqual(result);
|
||||
});
|
||||
it("should generate the file name for a new file", function() {
|
||||
it("should generate the file name for a new file", () => {
|
||||
const result = renderUtils.filenameDiff({
|
||||
oldName: "/dev/null",
|
||||
newName: "src/my/file.js"
|
||||
|
|
@ -71,8 +71,8 @@ describe("Utils", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("diffHighlight", function() {
|
||||
it("should highlight two lines", function() {
|
||||
describe("diffHighlight", () => {
|
||||
it("should highlight two lines", () => {
|
||||
const result = renderUtils.diffHighlight("-var myVar = 2;", "+var myVariable = 3;", false, {
|
||||
matching: LineMatchingType.WORDS
|
||||
});
|
||||
|
|
@ -88,7 +88,7 @@ describe("Utils", function() {
|
|||
}
|
||||
});
|
||||
});
|
||||
it("should highlight two lines char by char", function() {
|
||||
it("should highlight two lines char by char", () => {
|
||||
const result = renderUtils.diffHighlight("-var myVar = 2;", "+var myVariable = 3;", false, {
|
||||
diffStyle: DiffStyleType.CHAR
|
||||
});
|
||||
|
|
@ -104,7 +104,7 @@ describe("Utils", function() {
|
|||
}
|
||||
}).toEqual(result);
|
||||
});
|
||||
it("should highlight combined diff lines", function() {
|
||||
it("should highlight combined diff lines", () => {
|
||||
const result = renderUtils.diffHighlight(" -var myVar = 2;", " +var myVariable = 3;", true, {
|
||||
diffStyle: DiffStyleType.WORD,
|
||||
matching: LineMatchingType.WORDS,
|
||||
|
|
|
|||
Loading…
Reference in a new issue