Commit 67c33084 authored by Clement Ho's avatar Clement Ho

Merge branch 'winh-jest-no-identical-title' into 'master'

Enable ESLint rule jest/no-identical-title

See merge request gitlab-org/gitlab-ce!27139
parents 7e897b00 f23737a4
......@@ -13,5 +13,6 @@ globals:
preloadFixtures: false
setFixtures: false
rules:
jest/no-identical-title: error
jest/no-focused-tests: error
jest/no-jasmine-globals: error
......@@ -9,60 +9,57 @@ describe('Multi-file editor library diff calculator', () => {
});
describe('modified', () => {
it('', () => {
const diff = computeDiff('123', '1234')[0];
expect(diff.added).toBeTruthy();
expect(diff.modified).toBeTruthy();
expect(diff.removed).toBeUndefined();
});
it('', () => {
const diff = computeDiff('123\n123\n123', '123\n1234\n123')[0];
expect(diff.added).toBeTruthy();
expect(diff.modified).toBeTruthy();
expect(diff.removed).toBeUndefined();
expect(diff.lineNumber).toBe(2);
});
it.each`
originalContent | newContent | lineNumber
${'123'} | ${'1234'} | ${1}
${'123\n123\n123'} | ${'123\n1234\n123'} | ${2}
`(
'marks line $lineNumber as added and modified but not removed',
({ originalContent, newContent, lineNumber }) => {
const diff = computeDiff(originalContent, newContent)[0];
expect(diff.added).toBeTruthy();
expect(diff.modified).toBeTruthy();
expect(diff.removed).toBeUndefined();
expect(diff.lineNumber).toBe(lineNumber);
},
);
});
describe('added', () => {
it('', () => {
const diff = computeDiff('123', '123\n123')[0];
expect(diff.added).toBeTruthy();
expect(diff.modified).toBeUndefined();
expect(diff.removed).toBeUndefined();
});
it('', () => {
const diff = computeDiff('123\n123\n123', '123\n123\n1234\n123')[0];
expect(diff.added).toBeTruthy();
expect(diff.modified).toBeUndefined();
expect(diff.removed).toBeUndefined();
expect(diff.lineNumber).toBe(3);
});
it.each`
originalContent | newContent | lineNumber
${'123'} | ${'123\n123'} | ${1}
${'123\n123\n123'} | ${'123\n123\n1234\n123'} | ${3}
`(
'marks line $lineNumber as added but not modified and not removed',
({ originalContent, newContent, lineNumber }) => {
const diff = computeDiff(originalContent, newContent)[0];
expect(diff.added).toBeTruthy();
expect(diff.modified).toBeUndefined();
expect(diff.removed).toBeUndefined();
expect(diff.lineNumber).toBe(lineNumber);
},
);
});
describe('removed', () => {
it('', () => {
const diff = computeDiff('123', '')[0];
expect(diff.added).toBeUndefined();
expect(diff.modified).toBeUndefined();
expect(diff.removed).toBeTruthy();
});
it('', () => {
const diff = computeDiff('123\n123\n123', '123\n123')[0];
expect(diff.added).toBeUndefined();
expect(diff.modified).toBeTruthy();
expect(diff.removed).toBeTruthy();
expect(diff.lineNumber).toBe(2);
});
it.each`
originalContent | newContent | lineNumber | modified
${'123'} | ${''} | ${1} | ${undefined}
${'123\n123\n123'} | ${'123\n123'} | ${2} | ${true}
`(
'marks line $lineNumber as removed',
({ originalContent, newContent, lineNumber, modified }) => {
const diff = computeDiff(originalContent, newContent)[0];
expect(diff.added).toBeUndefined();
expect(diff.modified).toBe(modified);
expect(diff.removed).toBeTruthy();
expect(diff.lineNumber).toBe(lineNumber);
},
);
});
it('includes line number of change', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment