arvid-e пре 1 месец
родитељ
комит
c1fa65aff7
1 измењених фајлова са 40 додато и 0 уклоњено
  1. 40 0
      apps/app/src/features/search/utils/disable-user-pages.spec.ts

+ 40 - 0
apps/app/src/features/search/utils/disable-user-pages.spec.ts

@@ -107,4 +107,44 @@ describe('excludeUserPagesFromQuery()', () => {
     expect(query.prefix).toContain(doubleSlashSub);
     expect(query.not_prefix).not.toContain(doubleSlashSub);
   });
+
+  it('should add /user to not_prefix when it is empty', () => {
+    const query: QueryTerms = {
+      match: [],
+      not_match: [],
+      phrase: [],
+      not_phrase: [],
+      prefix: [],
+      not_prefix: [],
+      tag: [],
+      not_tag: [],
+    };
+
+    excludeUserPagesFromQuery(query);
+
+    expect(query.prefix).toHaveLength(0);
+    expect(query.not_prefix).toContain('/user');
+    expect(query.not_prefix).toHaveLength(1);
+  });
+
+  it('should remove existing /user strings and leave not_prefix with just one /user string', () => {
+    const userString = '/user';
+
+    const query: QueryTerms = {
+      match: [],
+      not_match: [],
+      phrase: [],
+      not_phrase: [],
+      prefix: [userString, userString],
+      not_prefix: [userString, userString],
+      tag: [],
+      not_tag: [],
+    };
+
+    excludeUserPagesFromQuery(query);
+
+    expect(query.prefix).toHaveLength(0);
+    expect(query.not_prefix).toContain('/user');
+    expect(query.not_prefix).toHaveLength(1);
+  });
 });