Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 21:08:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 21:08:11 +0300
commit8a7efa45c38ed3200d173d2c3207a8154e583c16 (patch)
tree1bb4d579b95c79aae4946a06fefa089e5549b722 /spec/frontend/notes/stores
parent53b1f4eaa2a451aaba908a5fee7ce97a930021ac (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/notes/stores')
-rw-r--r--spec/frontend/notes/stores/collapse_utils_spec.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/frontend/notes/stores/collapse_utils_spec.js b/spec/frontend/notes/stores/collapse_utils_spec.js
new file mode 100644
index 00000000000..d3019f4b9a4
--- /dev/null
+++ b/spec/frontend/notes/stores/collapse_utils_spec.js
@@ -0,0 +1,37 @@
+import {
+ isDescriptionSystemNote,
+ getTimeDifferenceMinutes,
+ collapseSystemNotes,
+} from '~/notes/stores/collapse_utils';
+import { notesWithDescriptionChanges, collapsedSystemNotes } from '../mock_data';
+
+describe('Collapse utils', () => {
+ const mockSystemNote = {
+ note: 'changed the description',
+ note_html: '<p dir="auto">changed the description</p>',
+ system: true,
+ created_at: '2018-05-14T21:28:00.000Z',
+ };
+
+ it('checks if a system note is of a description type', () => {
+ expect(isDescriptionSystemNote(mockSystemNote)).toEqual(true);
+ });
+
+ it('returns false when a system note is not a description type', () => {
+ expect(isDescriptionSystemNote(Object.assign({}, mockSystemNote, { note: 'foo' }))).toEqual(
+ false,
+ );
+ });
+
+ it('gets the time difference between two notes', () => {
+ const anotherSystemNote = {
+ created_at: '2018-05-14T21:33:00.000Z',
+ };
+
+ expect(getTimeDifferenceMinutes(mockSystemNote, anotherSystemNote)).toEqual(5);
+ });
+
+ it('collapses all description system notes made within 10 minutes or less from each other', () => {
+ expect(collapseSystemNotes(notesWithDescriptionChanges)).toEqual(collapsedSystemNotes);
+ });
+});