}),
mockFlowLocation({
component: 'a',
- textRange: { startLine: 54, endLine: 54, startOffset: 0, endOffset: 0 }
+ textRange: { startLine: 74, endLine: 74, startOffset: 0, endOffset: 0 }
})
],
- ...mockSnippetsByComponent('a', [...range(2, 17), ...range(29, 39), ...range(49, 59)])
+ ...mockSnippetsByComponent('a', [...range(2, 17), ...range(29, 39), ...range(69, 79)])
};
const wrapper = shallowRender({ issue, snippetGroup });
expect(wrapper.state('snippets')).toHaveLength(3);
expect(wrapper.state('snippets')[0]).toEqual({ index: 0, start: 2, end: 16 });
expect(wrapper.state('snippets')[1]).toEqual({ index: 1, start: 29, end: 39 });
- expect(wrapper.state('snippets')[2]).toEqual({ index: 2, start: 49, end: 59 });
+ expect(wrapper.state('snippets')[2]).toEqual({ index: 2, start: 69, end: 79 });
});
it('should expand block', async () => {
Object.values(mockSnippetsByComponent('a', range(6, 59)).sources)
);
const issue = mockIssue(true, {
- textRange: { startLine: 64, endLine: 64, startOffset: 5, endOffset: 10 }
+ textRange: { startLine: 74, endLine: 74, startOffset: 5, endOffset: 10 }
});
const snippetGroup: T.SnippetGroup = {
locations: [
mockFlowLocation({
component: 'a',
- textRange: { startLine: 64, endLine: 64, startOffset: 0, endOffset: 0 }
+ textRange: { startLine: 74, endLine: 74, startOffset: 0, endOffset: 0 }
}),
mockFlowLocation({
component: 'a',
- textRange: { startLine: 87, endLine: 87, startOffset: 0, endOffset: 0 }
+ textRange: { startLine: 107, endLine: 107, startOffset: 0, endOffset: 0 }
})
],
- ...mockSnippetsByComponent('a', [...range(59, 73), ...range(82, 92)])
+ ...mockSnippetsByComponent('a', [...range(69, 83), ...range(102, 112)])
};
const wrapper = shallowRender({ issue, snippetGroup });
wrapper.instance().expandBlock(0, 'up');
await waitAndUpdate(wrapper);
- expect(getSources).toHaveBeenCalledWith({ from: 6, key: 'a', to: 58 });
+ expect(getSources).toHaveBeenCalledWith({ from: 9, key: 'a', to: 68 });
expect(wrapper.state('snippets')).toHaveLength(2);
- expect(wrapper.state('snippets')[0]).toEqual({ index: 0, start: 9, end: 73 });
+ expect(wrapper.state('snippets')[0]).toEqual({ index: 0, start: 19, end: 83 });
expect(Object.keys(wrapper.state('additionalLines'))).toHaveLength(53);
});
wrapper.instance().expandBlock(0, 'down');
await waitAndUpdate(wrapper);
- expect(getSources).toHaveBeenCalledWith({ branch: 'asdf', from: 8, key: 'a', to: 60 });
+ expect(getSources).toHaveBeenCalledWith({ branch: 'asdf', from: 8, key: 'a', to: 67 });
});
it('should handle correctly open/close issue', () => {
it("should prepend the issue's main location if necessary", () => {
const locations = [
mockFlowLocation({
- textRange: { startLine: 65, startOffset: 2, endLine: 65, endOffset: 3 }
+ textRange: { startLine: 85, startOffset: 2, endLine: 85, endOffset: 3 }
}),
mockFlowLocation({
- textRange: { startLine: 32, startOffset: 2, endLine: 32, endOffset: 3 }
+ textRange: { startLine: 42, startOffset: 2, endLine: 42, endOffset: 3 }
})
];
const results = createSnippets({
it('should merge snippets if necessary', () => {
const snippets = [
{ index: 1, start: 4, end: 14 },
- { index: 2, start: 72, end: 82 },
+ { index: 2, start: 82, end: 92 },
{ index: 3, start: 37, end: 47 }
];
expect(result).toHaveLength(3);
expect(result[0]).toEqual({ index: 1, start: 4, end: 64 });
- expect(result[1]).toEqual({ index: 2, start: 72, end: 82 });
+ expect(result[1]).toEqual({ index: 2, start: 82, end: 92 });
expect(result[2]).toEqual({ index: 3, start: 37, end: 47, toDelete: true });
});
});
TreeSet<Integer> lines = linesPerComponent.computeIfAbsent(componentUuid, c -> new TreeSet<>());
IntStream.rangeClosed(start, end).forEach(lines::add);
- // If two snippets in the same component are 3 lines apart of each other, include those 3 lines.
+ // If two snippets in the same component are 10 lines apart of each other, include those 10 lines.
Integer closestToStart = lines.lower(start);
- if (closestToStart != null && closestToStart >= start - 4) {
+ if (closestToStart != null && closestToStart >= start - 11) {
IntStream.range(closestToStart + 1, start).forEach(lines::add);
}
Integer closestToEnd = lines.higher(end);
- if (closestToEnd != null && closestToEnd <= end + 4) {
+ if (closestToEnd != null && closestToEnd <= end + 11) {
IntStream.range(end + 1, closestToEnd).forEach(lines::add);
}