From 2ae45cebbf2ec839bf2280765f958eb60d1f6374 Mon Sep 17 00:00:00 2001 From: Roger Luo Date: Thu, 9 Jun 2022 19:15:08 +0800 Subject: Feature: Find files in repo (#15028) * Create finding files page ui in repo page * Get tree entries for find repo files. * Move find files JS to individual file. * gen swagger. * Add enry.IsVendor to exclude entries Co-authored-by: delvh Co-authored-by: wxiaoguang Co-authored-by: Lunny Xiao --- web_src/js/utils.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'web_src/js/utils.test.js') diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js index 3f6f921079..acf3f1ece3 100644 --- a/web_src/js/utils.test.js +++ b/web_src/js/utils.test.js @@ -1,5 +1,5 @@ import { - basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref, + basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref, strSubMatch, } from './utils.js'; test('basename', () => { @@ -84,3 +84,17 @@ test('parseIssueHref', () => { expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1#hash')).toEqual({owner: 'owner', repo: 'repo', type: 'issues', index: '1'}); expect(parseIssueHref('')).toEqual({owner: undefined, repo: undefined, type: undefined, index: undefined}); }); + + +test('strSubMatch', () => { + expect(strSubMatch('abc', '')).toEqual(['abc']); + expect(strSubMatch('abc', 'a')).toEqual(['', 'a', 'bc']); + expect(strSubMatch('abc', 'b')).toEqual(['a', 'b', 'c']); + expect(strSubMatch('abc', 'c')).toEqual(['ab', 'c']); + expect(strSubMatch('abc', 'ac')).toEqual(['', 'a', 'b', 'c']); + expect(strSubMatch('abc', 'z')).toEqual(['abc']); + expect(strSubMatch('abc', 'az')).toEqual(['abc']); + + expect(strSubMatch('aabbcc', 'abc')).toEqual(['', 'a', 'a', 'b', 'b', 'c', 'c']); + expect(strSubMatch('the/directory', 'hedir')).toEqual(['t', 'he', '/', 'dir', 'ectory']); +}); -- cgit v1.2.3