2021-11-11 11:23:49 +05:30
import * as getters from '~/header_search/store/getters' ;
import initState from '~/header_search/store/state' ;
import {
MOCK _USERNAME ,
MOCK _SEARCH _PATH ,
MOCK _ISSUE _PATH ,
MOCK _MR _PATH ,
2021-11-18 22:05:49 +05:30
MOCK _AUTOCOMPLETE _PATH ,
2021-11-11 11:23:49 +05:30
MOCK _SEARCH _CONTEXT ,
MOCK _DEFAULT _SEARCH _OPTIONS ,
MOCK _SCOPED _SEARCH _OPTIONS ,
2022-08-13 15:12:31 +05:30
MOCK _SCOPED _SEARCH _OPTIONS _DEF ,
2021-11-11 11:23:49 +05:30
MOCK _PROJECT ,
MOCK _GROUP ,
MOCK _ALL _PATH ,
MOCK _SEARCH ,
2021-11-18 22:05:49 +05:30
MOCK _AUTOCOMPLETE _OPTIONS ,
MOCK _GROUPED _AUTOCOMPLETE _OPTIONS ,
2022-01-26 12:08:38 +05:30
MOCK _SORTED _AUTOCOMPLETE _OPTIONS ,
2021-11-11 11:23:49 +05:30
} from '../mock_data' ;
describe ( 'Header Search Store Getters' , ( ) => {
let state ;
const createState = ( initialState ) => {
state = initState ( {
searchPath : MOCK _SEARCH _PATH ,
issuesPath : MOCK _ISSUE _PATH ,
mrPath : MOCK _MR _PATH ,
2021-11-18 22:05:49 +05:30
autocompletePath : MOCK _AUTOCOMPLETE _PATH ,
2021-11-11 11:23:49 +05:30
searchContext : MOCK _SEARCH _CONTEXT ,
... initialState ,
} ) ;
} ;
afterEach ( ( ) => {
state = null ;
} ) ;
describe . each `
2022-05-07 20:08:51 +05:30
group | project | scope | forSnippets | codeSearch | ref | expectedPath
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { null } | $ { null } | $ { null } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&snippets=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&search_code=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&repository_ref=test-branch ` }
$ { MOCK _GROUP } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } ` }
$ { null } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true&search_code=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true&search_code=true&repository_ref=test-branch ` }
` ('searchQuery', ({ group, project, scope, forSnippets, codeSearch, ref, expectedPath }) => {
describe ( ` when group is ${ group ? . name } , project is ${ project ? . name } , scope is ${ scope } , for_snippets is ${ forSnippets } , code_search is ${ codeSearch } , and ref is ${ ref } ` , ( ) => {
2021-11-11 11:23:49 +05:30
beforeEach ( ( ) => {
createState ( {
searchContext : {
group ,
project ,
2022-01-26 12:08:38 +05:30
scope ,
2022-05-07 20:08:51 +05:30
for _snippets : forSnippets ,
code _search : codeSearch ,
ref ,
2021-11-11 11:23:49 +05:30
} ,
} ) ;
state . search = MOCK _SEARCH ;
} ) ;
it ( ` should return ${ expectedPath } ` , ( ) => {
expect ( getters . searchQuery ( state ) ) . toBe ( expectedPath ) ;
} ) ;
} ) ;
} ) ;
describe . each `
group | group _metadata | project | project _metadata | expectedPath
$ { null } | $ { null } | $ { null } | $ { null } | $ { MOCK _ISSUE _PATH }
$ { { name : 'Test Group' } } | $ { { issues _path : 'group/path' } } | $ { null } | $ { null } | $ { 'group/path' }
$ { { name : 'Test Group' } } | $ { { issues _path : 'group/path' } } | $ { { name : 'Test Project' } } | $ { { issues _path : 'project/path' } } | $ { 'project/path' }
` ('scopedIssuesPath', ({ group, group_metadata, project, project_metadata, expectedPath }) => {
describe ( ` when group is ${ group ? . name } and project is ${ project ? . name } ` , ( ) => {
beforeEach ( ( ) => {
createState ( {
searchContext : {
group ,
group _metadata ,
project ,
project _metadata ,
} ,
} ) ;
} ) ;
it ( ` should return ${ expectedPath } ` , ( ) => {
expect ( getters . scopedIssuesPath ( state ) ) . toBe ( expectedPath ) ;
} ) ;
} ) ;
} ) ;
describe . each `
group | group _metadata | project | project _metadata | expectedPath
$ { null } | $ { null } | $ { null } | $ { null } | $ { MOCK _MR _PATH }
$ { { name : 'Test Group' } } | $ { { mr _path : 'group/path' } } | $ { null } | $ { null } | $ { 'group/path' }
$ { { name : 'Test Group' } } | $ { { mr _path : 'group/path' } } | $ { { name : 'Test Project' } } | $ { { mr _path : 'project/path' } } | $ { 'project/path' }
` ('scopedMRPath', ({ group, group_metadata, project, project_metadata, expectedPath }) => {
describe ( ` when group is ${ group ? . name } and project is ${ project ? . name } ` , ( ) => {
beforeEach ( ( ) => {
createState ( {
searchContext : {
group ,
group _metadata ,
project ,
project _metadata ,
} ,
} ) ;
} ) ;
it ( ` should return ${ expectedPath } ` , ( ) => {
expect ( getters . scopedMRPath ( state ) ) . toBe ( expectedPath ) ;
} ) ;
} ) ;
} ) ;
describe . each `
2022-05-07 20:08:51 +05:30
group | project | scope | forSnippets | codeSearch | ref | expectedPath
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { null } | $ { null } | $ { null } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&snippets=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&search_code=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&repository_ref=test-branch ` }
$ { MOCK _GROUP } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } ` }
$ { null } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true&search_code=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&project_id= ${ MOCK _PROJECT . id } &group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true&search_code=true&repository_ref=test-branch ` }
` ('projectUrl', ({ group, project, scope, forSnippets, codeSearch, ref, expectedPath }) => {
describe ( ` when group is ${ group ? . name } , project is ${ project ? . name } , scope is ${ scope } , for_snippets is ${ forSnippets } , code_search is ${ codeSearch } , and ref is ${ ref } ` , ( ) => {
2021-11-11 11:23:49 +05:30
beforeEach ( ( ) => {
createState ( {
searchContext : {
group ,
project ,
2022-01-26 12:08:38 +05:30
scope ,
2022-05-07 20:08:51 +05:30
for _snippets : forSnippets ,
code _search : codeSearch ,
ref ,
2021-11-11 11:23:49 +05:30
} ,
} ) ;
state . search = MOCK _SEARCH ;
} ) ;
it ( ` should return ${ expectedPath } ` , ( ) => {
expect ( getters . projectUrl ( state ) ) . toBe ( expectedPath ) ;
} ) ;
} ) ;
} ) ;
describe . each `
2022-05-07 20:08:51 +05:30
group | project | scope | forSnippets | codeSearch | ref | expectedPath
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { null } | $ { null } | $ { null } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&snippets=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&search_code=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&repository_ref=test-branch ` }
$ { MOCK _GROUP } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } ` }
$ { null } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } &scope=issues ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true&search_code=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&group_id= ${ MOCK _GROUP . id } &scope=issues&snippets=true&search_code=true&repository_ref=test-branch ` }
` ('groupUrl', ({ group, project, scope, forSnippets, codeSearch, ref, expectedPath }) => {
describe ( ` when group is ${ group ? . name } , project is ${ project ? . name } , scope is ${ scope } , for_snippets is ${ forSnippets } , code_search is ${ codeSearch } , and ref is ${ ref } ` , ( ) => {
2021-11-11 11:23:49 +05:30
beforeEach ( ( ) => {
createState ( {
searchContext : {
group ,
project ,
2022-01-26 12:08:38 +05:30
scope ,
2022-05-07 20:08:51 +05:30
for _snippets : forSnippets ,
code _search : codeSearch ,
ref ,
2021-11-11 11:23:49 +05:30
} ,
} ) ;
state . search = MOCK _SEARCH ;
} ) ;
it ( ` should return ${ expectedPath } ` , ( ) => {
expect ( getters . groupUrl ( state ) ) . toBe ( expectedPath ) ;
} ) ;
} ) ;
} ) ;
2022-01-26 12:08:38 +05:30
describe . each `
2022-05-07 20:08:51 +05:30
group | project | scope | forSnippets | codeSearch | ref | expectedPath
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { null } | $ { null } | $ { null } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&snippets=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&search_code=true ` }
$ { null } | $ { null } | $ { null } | $ { false } | $ { false } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&repository_ref=test-branch ` }
$ { MOCK _GROUP } | $ { null } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { null } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { null } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { false } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&scope=issues ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { false } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&scope=issues&snippets=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { null } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&scope=issues&snippets=true&search_code=true ` }
$ { MOCK _GROUP } | $ { MOCK _PROJECT } | $ { 'issues' } | $ { true } | $ { true } | $ { 'test-branch' } | $ { ` ${ MOCK _SEARCH _PATH } ?search= ${ MOCK _SEARCH } &nav_source=navbar&scope=issues&snippets=true&search_code=true&repository_ref=test-branch ` }
` ('allUrl', ({ group, project, scope, forSnippets, codeSearch, ref, expectedPath }) => {
describe ( ` when group is ${ group ? . name } , project is ${ project ? . name } , scope is ${ scope } , for_snippets is ${ forSnippets } , code_search is ${ codeSearch } , and ref is ${ ref } ` , ( ) => {
2022-01-26 12:08:38 +05:30
beforeEach ( ( ) => {
createState ( {
searchContext : {
group ,
project ,
scope ,
2022-05-07 20:08:51 +05:30
for _snippets : forSnippets ,
code _search : codeSearch ,
ref ,
2022-01-26 12:08:38 +05:30
} ,
} ) ;
state . search = MOCK _SEARCH ;
2021-11-11 11:23:49 +05:30
} ) ;
2022-01-26 12:08:38 +05:30
it ( ` should return ${ expectedPath } ` , ( ) => {
expect ( getters . allUrl ( state ) ) . toBe ( expectedPath ) ;
} ) ;
2021-11-11 11:23:49 +05:30
} ) ;
} ) ;
describe ( 'defaultSearchOptions' , ( ) => {
const mockGetters = {
scopedIssuesPath : MOCK _ISSUE _PATH ,
scopedMRPath : MOCK _MR _PATH ,
} ;
beforeEach ( ( ) => {
createState ( ) ;
window . gon . current _username = MOCK _USERNAME ;
} ) ;
it ( 'returns the correct array' , ( ) => {
expect ( getters . defaultSearchOptions ( state , mockGetters ) ) . toStrictEqual (
MOCK _DEFAULT _SEARCH _OPTIONS ,
) ;
} ) ;
2023-05-27 22:25:52 +05:30
it ( 'returns the correct array if issues path is false' , ( ) => {
mockGetters . scopedIssuesPath = undefined ;
expect ( getters . defaultSearchOptions ( state , mockGetters ) ) . toStrictEqual (
MOCK _DEFAULT _SEARCH _OPTIONS . slice ( 2 , MOCK _DEFAULT _SEARCH _OPTIONS . length ) ,
) ;
} ) ;
2021-11-11 11:23:49 +05:30
} ) ;
describe ( 'scopedSearchOptions' , ( ) => {
const mockGetters = {
projectUrl : MOCK _PROJECT . path ,
groupUrl : MOCK _GROUP . path ,
allUrl : MOCK _ALL _PATH ,
} ;
beforeEach ( ( ) => {
createState ( {
searchContext : {
project : MOCK _PROJECT ,
group : MOCK _GROUP ,
} ,
} ) ;
} ) ;
it ( 'returns the correct array' , ( ) => {
expect ( getters . scopedSearchOptions ( state , mockGetters ) ) . toStrictEqual (
2022-08-13 15:12:31 +05:30
MOCK _SCOPED _SEARCH _OPTIONS _DEF ,
2021-11-11 11:23:49 +05:30
) ;
} ) ;
} ) ;
2021-11-18 22:05:49 +05:30
describe ( 'autocompleteGroupedSearchOptions' , ( ) => {
beforeEach ( ( ) => {
createState ( ) ;
state . autocompleteOptions = MOCK _AUTOCOMPLETE _OPTIONS ;
} ) ;
it ( 'returns the correct grouped array' , ( ) => {
expect ( getters . autocompleteGroupedSearchOptions ( state ) ) . toStrictEqual (
MOCK _GROUPED _AUTOCOMPLETE _OPTIONS ,
) ;
} ) ;
} ) ;
2022-01-26 12:08:38 +05:30
describe . each `
search | defaultSearchOptions | scopedSearchOptions | autocompleteGroupedSearchOptions | expectedArray
$ { null } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS } | $ { MOCK _GROUPED _AUTOCOMPLETE _OPTIONS } | $ { MOCK _DEFAULT _SEARCH _OPTIONS }
$ { MOCK _SEARCH } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS } | $ { [ ] } | $ { MOCK _SCOPED _SEARCH _OPTIONS }
$ { MOCK _SEARCH } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { [ ] } | $ { MOCK _GROUPED _AUTOCOMPLETE _OPTIONS } | $ { MOCK _SORTED _AUTOCOMPLETE _OPTIONS }
$ { MOCK _SEARCH } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS } | $ { MOCK _GROUPED _AUTOCOMPLETE _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS . concat ( MOCK _SORTED _AUTOCOMPLETE _OPTIONS ) }
2022-08-13 15:12:31 +05:30
$ { 1 } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { [ ] } | $ { [ ] } | $ { [ ] }
$ { '(' } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { [ ] } | $ { [ ] } | $ { [ ] }
$ { 't' } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS } | $ { MOCK _GROUPED _AUTOCOMPLETE _OPTIONS } | $ { MOCK _SORTED _AUTOCOMPLETE _OPTIONS }
$ { 'te' } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS } | $ { MOCK _GROUPED _AUTOCOMPLETE _OPTIONS } | $ { MOCK _SORTED _AUTOCOMPLETE _OPTIONS }
$ { 'tes' } | $ { MOCK _DEFAULT _SEARCH _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS } | $ { MOCK _GROUPED _AUTOCOMPLETE _OPTIONS } | $ { MOCK _SCOPED _SEARCH _OPTIONS . concat ( MOCK _SORTED _AUTOCOMPLETE _OPTIONS ) }
2022-01-26 12:08:38 +05:30
` (
'searchOptions' ,
( {
search ,
defaultSearchOptions ,
scopedSearchOptions ,
autocompleteGroupedSearchOptions ,
expectedArray ,
} ) => {
describe ( ` when search is ${ search } and the defaultSearchOptions ${
defaultSearchOptions . length ? '' : ' do not'
} exist , scopedSearchOptions$ {
scopedSearchOptions . length ? '' : ' do not'
} exist , and autocompleteGroupedSearchOptions$ {
autocompleteGroupedSearchOptions . length ? '' : ' do not'
} exist ` , () => {
const mockGetters = {
defaultSearchOptions ,
scopedSearchOptions ,
autocompleteGroupedSearchOptions ,
} ;
beforeEach ( ( ) => {
createState ( ) ;
state . search = search ;
} ) ;
it ( ` should return the correct combined array ` , ( ) => {
expect ( getters . searchOptions ( state , mockGetters ) ) . toStrictEqual ( expectedArray ) ;
} ) ;
} ) ;
} ,
) ;
2021-11-11 11:23:49 +05:30
} ) ;