diff options
Diffstat (limited to 'spec/javascripts/filtered_search/filtered_search_token_keys_spec.js')
-rw-r--r-- | spec/javascripts/filtered_search/filtered_search_token_keys_spec.js | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js b/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js index 20264caa5c4..d1fea18dea8 100644 --- a/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js +++ b/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js @@ -1,23 +1,26 @@ import FilteredSearchTokenKeys from '~/filtered_search/filtered_search_token_keys'; describe('Filtered Search Token Keys', () => { - const tokenKeys = [{ - key: 'author', - type: 'string', - param: 'username', - symbol: '@', - icon: 'pencil', - tag: '@author', - }]; - - const conditions = [{ - url: 'assignee_id=0', - tokenKey: 'assignee', - value: 'none', - }]; + const tokenKeys = [ + { + key: 'author', + type: 'string', + param: 'username', + symbol: '@', + icon: 'pencil', + tag: '@author', + }, + ]; + + const conditions = [ + { + url: 'assignee_id=0', + tokenKey: 'assignee', + value: 'none', + }, + ]; describe('get', () => { - it('should return tokenKeys', () => { expect(new FilteredSearchTokenKeys().get()).not.toBeNull(); }); @@ -84,13 +87,17 @@ describe('Filtered Search Token Keys', () => { }); it('should return tokenKey when found by key param', () => { - const result = new FilteredSearchTokenKeys(tokenKeys).searchByKeyParam(`${tokenKeys[0].key}_${tokenKeys[0].param}`); + const result = new FilteredSearchTokenKeys(tokenKeys).searchByKeyParam( + `${tokenKeys[0].key}_${tokenKeys[0].param}`, + ); expect(result).toEqual(tokenKeys[0]); }); it('should return alternative tokenKey when found by key param', () => { - const result = new FilteredSearchTokenKeys(tokenKeys).searchByKeyParam(`${tokenKeys[0].key}_${tokenKeys[0].param}`); + const result = new FilteredSearchTokenKeys(tokenKeys).searchByKeyParam( + `${tokenKeys[0].key}_${tokenKeys[0].param}`, + ); expect(result).toEqual(tokenKeys[0]); }); @@ -104,8 +111,9 @@ describe('Filtered Search Token Keys', () => { }); it('should return condition when found by url', () => { - const result = new FilteredSearchTokenKeys([], [], conditions) - .searchByConditionUrl(conditions[0].url); + const result = new FilteredSearchTokenKeys([], [], conditions).searchByConditionUrl( + conditions[0].url, + ); expect(result).toBe(conditions[0]); }); @@ -113,15 +121,19 @@ describe('Filtered Search Token Keys', () => { describe('searchByConditionKeyValue', () => { it('should return null when condition tokenKey and value not found', () => { - const condition = new FilteredSearchTokenKeys([], [], conditions) - .searchByConditionKeyValue(null, null); + const condition = new FilteredSearchTokenKeys([], [], conditions).searchByConditionKeyValue( + null, + null, + ); expect(condition).toBeNull(); }); it('should return condition when found by tokenKey and value', () => { - const result = new FilteredSearchTokenKeys([], [], conditions) - .searchByConditionKeyValue(conditions[0].tokenKey, conditions[0].value); + const result = new FilteredSearchTokenKeys([], [], conditions).searchByConditionKeyValue( + conditions[0].tokenKey, + conditions[0].value, + ); expect(result).toEqual(conditions[0]); }); |