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:
authorWinnie Hellmann <winnie@gitlab.com>2019-03-23 19:52:35 +0300
committerWinnie Hellmann <winnie@gitlab.com>2019-03-23 19:53:46 +0300
commit514ee63826e47229bfd03bdbb740f2dd1eae1d03 (patch)
tree3f0d96a4402e8aa54c375084cc4c5e6cf546824b /spec/javascripts/filtered_search
parent6d330015dfdb1979a0773c87c53b84cc86b28a6d (diff)
Move some tests from Karma to Jest
Diffstat (limited to 'spec/javascripts/filtered_search')
-rw-r--r--spec/javascripts/filtered_search/filtered_search_token_keys_spec.js141
-rw-r--r--spec/javascripts/filtered_search/services/recent_searches_service_error_spec.js18
-rw-r--r--spec/javascripts/filtered_search/stores/recent_searches_store_spec.js53
3 files changed, 0 insertions, 212 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
deleted file mode 100644
index d1fea18dea8..00000000000
--- a/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js
+++ /dev/null
@@ -1,141 +0,0 @@
-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',
- },
- ];
-
- describe('get', () => {
- it('should return tokenKeys', () => {
- expect(new FilteredSearchTokenKeys().get()).not.toBeNull();
- });
-
- it('should return tokenKeys as an array', () => {
- expect(new FilteredSearchTokenKeys().get() instanceof Array).toBe(true);
- });
- });
-
- describe('getKeys', () => {
- it('should return keys', () => {
- const getKeys = new FilteredSearchTokenKeys(tokenKeys).getKeys();
- const keys = new FilteredSearchTokenKeys(tokenKeys).get().map(i => i.key);
-
- keys.forEach((key, i) => {
- expect(key).toEqual(getKeys[i]);
- });
- });
- });
-
- describe('getConditions', () => {
- it('should return conditions', () => {
- expect(new FilteredSearchTokenKeys().getConditions()).not.toBeNull();
- });
-
- it('should return conditions as an array', () => {
- expect(new FilteredSearchTokenKeys().getConditions() instanceof Array).toBe(true);
- });
- });
-
- describe('searchByKey', () => {
- it('should return null when key not found', () => {
- const tokenKey = new FilteredSearchTokenKeys(tokenKeys).searchByKey('notakey');
-
- expect(tokenKey).toBeNull();
- });
-
- it('should return tokenKey when found by key', () => {
- const result = new FilteredSearchTokenKeys(tokenKeys).searchByKey(tokenKeys[0].key);
-
- expect(result).toEqual(tokenKeys[0]);
- });
- });
-
- describe('searchBySymbol', () => {
- it('should return null when symbol not found', () => {
- const tokenKey = new FilteredSearchTokenKeys(tokenKeys).searchBySymbol('notasymbol');
-
- expect(tokenKey).toBeNull();
- });
-
- it('should return tokenKey when found by symbol', () => {
- const result = new FilteredSearchTokenKeys(tokenKeys).searchBySymbol(tokenKeys[0].symbol);
-
- expect(result).toEqual(tokenKeys[0]);
- });
- });
-
- describe('searchByKeyParam', () => {
- it('should return null when key param not found', () => {
- const tokenKey = new FilteredSearchTokenKeys(tokenKeys).searchByKeyParam('notakeyparam');
-
- expect(tokenKey).toBeNull();
- });
-
- it('should return tokenKey when found by key 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}`,
- );
-
- expect(result).toEqual(tokenKeys[0]);
- });
- });
-
- describe('searchByConditionUrl', () => {
- it('should return null when condition url not found', () => {
- const condition = new FilteredSearchTokenKeys([], [], conditions).searchByConditionUrl(null);
-
- expect(condition).toBeNull();
- });
-
- it('should return condition when found by url', () => {
- const result = new FilteredSearchTokenKeys([], [], conditions).searchByConditionUrl(
- conditions[0].url,
- );
-
- expect(result).toBe(conditions[0]);
- });
- });
-
- describe('searchByConditionKeyValue', () => {
- it('should return null when condition tokenKey and value not found', () => {
- 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,
- );
-
- expect(result).toEqual(conditions[0]);
- });
- });
-});
diff --git a/spec/javascripts/filtered_search/services/recent_searches_service_error_spec.js b/spec/javascripts/filtered_search/services/recent_searches_service_error_spec.js
deleted file mode 100644
index ea7c146fa4f..00000000000
--- a/spec/javascripts/filtered_search/services/recent_searches_service_error_spec.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import RecentSearchesServiceError from '~/filtered_search/services/recent_searches_service_error';
-
-describe('RecentSearchesServiceError', () => {
- let recentSearchesServiceError;
-
- beforeEach(() => {
- recentSearchesServiceError = new RecentSearchesServiceError();
- });
-
- it('instantiates an instance of RecentSearchesServiceError and not an Error', () => {
- expect(recentSearchesServiceError).toEqual(jasmine.any(RecentSearchesServiceError));
- expect(recentSearchesServiceError.name).toBe('RecentSearchesServiceError');
- });
-
- it('should set a default message', () => {
- expect(recentSearchesServiceError.message).toBe('Recent Searches Service is unavailable');
- });
-});
diff --git a/spec/javascripts/filtered_search/stores/recent_searches_store_spec.js b/spec/javascripts/filtered_search/stores/recent_searches_store_spec.js
deleted file mode 100644
index 56bb82ae941..00000000000
--- a/spec/javascripts/filtered_search/stores/recent_searches_store_spec.js
+++ /dev/null
@@ -1,53 +0,0 @@
-import RecentSearchesStore from '~/filtered_search/stores/recent_searches_store';
-
-describe('RecentSearchesStore', () => {
- let store;
-
- beforeEach(() => {
- store = new RecentSearchesStore();
- });
-
- describe('addRecentSearch', () => {
- it('should add to the front of the list', () => {
- store.addRecentSearch('foo');
- store.addRecentSearch('bar');
-
- expect(store.state.recentSearches).toEqual(['bar', 'foo']);
- });
-
- it('should deduplicate', () => {
- store.addRecentSearch('foo');
- store.addRecentSearch('bar');
- store.addRecentSearch('foo');
-
- expect(store.state.recentSearches).toEqual(['foo', 'bar']);
- });
-
- it('only keeps track of 5 items', () => {
- store.addRecentSearch('1');
- store.addRecentSearch('2');
- store.addRecentSearch('3');
- store.addRecentSearch('4');
- store.addRecentSearch('5');
- store.addRecentSearch('6');
- store.addRecentSearch('7');
-
- expect(store.state.recentSearches).toEqual(['7', '6', '5', '4', '3']);
- });
- });
-
- describe('setRecentSearches', () => {
- it('should override list', () => {
- store.setRecentSearches(['foo', 'bar']);
- store.setRecentSearches(['baz', 'qux']);
-
- expect(store.state.recentSearches).toEqual(['baz', 'qux']);
- });
-
- it('only keeps track of 5 items', () => {
- store.setRecentSearches(['1', '2', '3', '4', '5', '6', '7']);
-
- expect(store.state.recentSearches).toEqual(['1', '2', '3', '4', '5']);
- });
- });
-});