Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b6a8d9ba
Commit
b6a8d9ba
authored
Dec 23, 2020
by
Lukas Eipert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run prettier on 44 files - 58 of 73
Part of our prettier migration; changing the arrow-parens style.
parent
9180eaee
Changes
45
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
162 additions
and
208 deletions
+162
-208
.prettierignore
.prettierignore
+0
-46
spec/frontend/filtered_search/filtered_search_manager_spec.js
.../frontend/filtered_search/filtered_search_manager_spec.js
+13
-13
spec/frontend/filtered_search/filtered_search_token_keys_spec.js
...ontend/filtered_search/filtered_search_token_keys_spec.js
+1
-1
spec/frontend/filtered_search/filtered_search_visual_tokens_spec.js
...end/filtered_search/filtered_search_visual_tokens_spec.js
+1
-1
spec/frontend/filtered_search/issues_filtered_search_token_keys_spec.js
...filtered_search/issues_filtered_search_token_keys_spec.js
+2
-2
spec/frontend/filtered_search/recent_searches_root_spec.js
spec/frontend/filtered_search/recent_searches_root_spec.js
+1
-1
spec/frontend/filtered_search/services/recent_searches_service_spec.js
.../filtered_search/services/recent_searches_service_spec.js
+10
-10
spec/frontend/filtered_search/visual_token_value_spec.js
spec/frontend/filtered_search/visual_token_value_spec.js
+17
-17
spec/frontend/flash_spec.js
spec/frontend/flash_spec.js
+1
-1
spec/frontend/frequent_items/components/app_spec.js
spec/frontend/frequent_items/components/app_spec.js
+7
-7
spec/frontend/frequent_items/components/frequent_items_list_item_spec.js
...requent_items/components/frequent_items_list_item_spec.js
+1
-1
spec/frontend/frequent_items/components/frequent_items_search_input_spec.js
...uent_items/components/frequent_items_search_input_spec.js
+2
-2
spec/frontend/frequent_items/store/actions_spec.js
spec/frontend/frequent_items/store/actions_spec.js
+14
-14
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gfm_auto_complete_spec.js
+17
-17
spec/frontend/gl_field_errors_spec.js
spec/frontend/gl_field_errors_spec.js
+1
-1
spec/frontend/gl_form_spec.js
spec/frontend/gl_form_spec.js
+2
-2
spec/frontend/gpg_badges_spec.js
spec/frontend/gpg_badges_spec.js
+5
-5
spec/frontend/group_settings/components/shared_runners_form_spec.js
...end/group_settings/components/shared_runners_form_spec.js
+1
-1
spec/frontend/groups/components/group_item_spec.js
spec/frontend/groups/components/group_item_spec.js
+4
-4
spec/frontend/groups/components/visibility_level_dropdown_spec.js
...ntend/groups/components/visibility_level_dropdown_spec.js
+2
-2
spec/frontend/helpers/backoff_helper.js
spec/frontend/helpers/backoff_helper.js
+2
-2
spec/frontend/helpers/dom_events_helper.js
spec/frontend/helpers/dom_events_helper.js
+1
-1
spec/frontend/helpers/dom_shims/size_properties.js
spec/frontend/helpers/dom_shims/size_properties.js
+1
-1
spec/frontend/helpers/emoji.js
spec/frontend/helpers/emoji.js
+5
-5
spec/frontend/helpers/event_hub_factory_spec.js
spec/frontend/helpers/event_hub_factory_spec.js
+5
-5
spec/frontend/helpers/fake_date.js
spec/frontend/helpers/fake_date.js
+3
-3
spec/frontend/helpers/fake_request_animation_frame.js
spec/frontend/helpers/fake_request_animation_frame.js
+1
-1
spec/frontend/helpers/fixtures.js
spec/frontend/helpers/fixtures.js
+1
-1
spec/frontend/helpers/jest_helpers.js
spec/frontend/helpers/jest_helpers.js
+1
-1
spec/frontend/helpers/local_storage_helper.js
spec/frontend/helpers/local_storage_helper.js
+3
-3
spec/frontend/helpers/locale_helper.js
spec/frontend/helpers/locale_helper.js
+1
-1
spec/frontend/helpers/mock_window_location_helper.js
spec/frontend/helpers/mock_window_location_helper.js
+1
-1
spec/frontend/helpers/set_timeout_promise_helper.js
spec/frontend/helpers/set_timeout_promise_helper.js
+1
-1
spec/frontend/helpers/set_window_location_helper_spec.js
spec/frontend/helpers/set_window_location_helper_spec.js
+1
-1
spec/frontend/helpers/startup_css_helper_spec.js
spec/frontend/helpers/startup_css_helper_spec.js
+1
-1
spec/frontend/helpers/stub_children.js
spec/frontend/helpers/stub_children.js
+1
-1
spec/frontend/helpers/text_helper.js
spec/frontend/helpers/text_helper.js
+3
-3
spec/frontend/helpers/timeout.js
spec/frontend/helpers/timeout.js
+3
-3
spec/frontend/helpers/tracking_helper.js
spec/frontend/helpers/tracking_helper.js
+1
-1
spec/frontend/helpers/vue_mock_directive.js
spec/frontend/helpers/vue_mock_directive.js
+1
-1
spec/frontend/helpers/vue_test_utils_helper.js
spec/frontend/helpers/vue_test_utils_helper.js
+5
-5
spec/frontend/helpers/vuex_action_helper.js
spec/frontend/helpers/vuex_action_helper.js
+3
-3
spec/frontend/helpers/vuex_action_helper_spec.js
spec/frontend/helpers/vuex_action_helper_spec.js
+12
-12
spec/frontend/helpers/wait_for_promises.js
spec/frontend/helpers/wait_for_promises.js
+1
-1
spec/frontend/helpers/wait_using_real_timer.js
spec/frontend/helpers/wait_using_real_timer.js
+2
-2
No files found.
.prettierignore
View file @
b6a8d9ba
...
...
@@ -1706,52 +1706,6 @@ spec/frontend/behaviors/markdown/paste_markdown_table_spec.js
spec/frontend/behaviors/quick_submit_spec.js
spec/frontend/behaviors/secret_values_spec.js
## determined-blackburn
spec/frontend/filtered_search/filtered_search_manager_spec.js
spec/frontend/filtered_search/filtered_search_token_keys_spec.js
spec/frontend/filtered_search/filtered_search_visual_tokens_spec.js
spec/frontend/filtered_search/issues_filtered_search_token_keys_spec.js
spec/frontend/filtered_search/recent_searches_root_spec.js
spec/frontend/filtered_search/services/recent_searches_service_spec.js
spec/frontend/filtered_search/visual_token_value_spec.js
spec/frontend/flash_spec.js
spec/frontend/frequent_items/components/app_spec.js
spec/frontend/frequent_items/components/frequent_items_list_item_spec.js
spec/frontend/frequent_items/components/frequent_items_search_input_spec.js
spec/frontend/frequent_items/store/actions_spec.js
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gl_field_errors_spec.js
spec/frontend/gl_form_spec.js
spec/frontend/gpg_badges_spec.js
spec/frontend/group_settings/components/shared_runners_form_spec.js
spec/frontend/groups/components/group_item_spec.js
spec/frontend/groups/components/visibility_level_dropdown_spec.js
spec/frontend/helpers/backoff_helper.js
spec/frontend/helpers/dom_events_helper.js
spec/frontend/helpers/dom_shims/size_properties.js
spec/frontend/helpers/emoji.js
spec/frontend/helpers/event_hub_factory_spec.js
spec/frontend/helpers/fake_date.js
spec/frontend/helpers/fake_request_animation_frame.js
spec/frontend/helpers/fixtures.js
spec/frontend/helpers/jest_helpers.js
spec/frontend/helpers/local_storage_helper.js
spec/frontend/helpers/locale_helper.js
spec/frontend/helpers/mock_window_location_helper.js
spec/frontend/helpers/set_timeout_promise_helper.js
spec/frontend/helpers/set_window_location_helper_spec.js
spec/frontend/helpers/startup_css_helper_spec.js
spec/frontend/helpers/stub_children.js
spec/frontend/helpers/text_helper.js
spec/frontend/helpers/timeout.js
spec/frontend/helpers/tracking_helper.js
spec/frontend/helpers/vue_mock_directive.js
spec/frontend/helpers/vue_test_utils_helper.js
spec/frontend/helpers/vuex_action_helper.js
spec/frontend/helpers/vuex_action_helper_spec.js
spec/frontend/helpers/wait_for_promises.js
spec/frontend/helpers/wait_using_real_timer.js
## condescending-haslett
spec/frontend/ide/components/activity_bar_spec.js
spec/frontend/ide/components/branches/search_list_spec.js
...
...
spec/frontend/filtered_search/filtered_search_manager_spec.js
View file @
b6a8d9ba
...
...
@@ -188,11 +188,11 @@ describe('Filtered Search Manager', () => {
const
defaultParams
=
'
?scope=all&utf8=%E2%9C%93
'
;
const
defaultState
=
'
&state=opened
'
;
it
(
'
should search with a single word
'
,
done
=>
{
it
(
'
should search with a single word
'
,
(
done
)
=>
{
initializeManager
();
input
.
value
=
'
searchTerm
'
;
visitUrl
.
mockImplementation
(
url
=>
{
visitUrl
.
mockImplementation
(
(
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}
&search=searchTerm`
);
done
();
});
...
...
@@ -200,11 +200,11 @@ describe('Filtered Search Manager', () => {
manager
.
search
();
});
it
(
'
sets default state
'
,
done
=>
{
it
(
'
sets default state
'
,
(
done
)
=>
{
initializeManager
({
useDefaultState
:
true
});
input
.
value
=
'
searchTerm
'
;
visitUrl
.
mockImplementation
(
url
=>
{
visitUrl
.
mockImplementation
(
(
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}${
defaultState
}
&search=searchTerm`
);
done
();
});
...
...
@@ -212,11 +212,11 @@ describe('Filtered Search Manager', () => {
manager
.
search
();
});
it
(
'
should search with multiple words
'
,
done
=>
{
it
(
'
should search with multiple words
'
,
(
done
)
=>
{
initializeManager
();
input
.
value
=
'
awesome search terms
'
;
visitUrl
.
mockImplementation
(
url
=>
{
visitUrl
.
mockImplementation
(
(
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}
&search=awesome+search+terms`
);
done
();
});
...
...
@@ -224,11 +224,11 @@ describe('Filtered Search Manager', () => {
manager
.
search
();
});
it
(
'
should search with special characters
'
,
done
=>
{
it
(
'
should search with special characters
'
,
(
done
)
=>
{
initializeManager
();
input
.
value
=
'
~!@#$%^&*()_+{}:<>,.?/
'
;
visitUrl
.
mockImplementation
(
url
=>
{
visitUrl
.
mockImplementation
(
(
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}
&search=~!%40%23%24%25%5E%26*()_%2B%7B%7D%3A%3C%3E%2C.%3F%2F`
,
);
...
...
@@ -238,13 +238,13 @@ describe('Filtered Search Manager', () => {
manager
.
search
();
});
it
(
'
should use replacement URL for condition
'
,
done
=>
{
it
(
'
should use replacement URL for condition
'
,
(
done
)
=>
{
initializeManager
();
tokensContainer
.
innerHTML
=
FilteredSearchSpecHelper
.
createTokensContainerHTML
(
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
milestone
'
,
'
=
'
,
'
13
'
,
true
),
);
visitUrl
.
mockImplementation
(
url
=>
{
visitUrl
.
mockImplementation
(
(
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}
&milestone_title=replaced`
);
done
();
});
...
...
@@ -259,14 +259,14 @@ describe('Filtered Search Manager', () => {
manager
.
search
();
});
it
(
'
removes duplicated tokens
'
,
done
=>
{
it
(
'
removes duplicated tokens
'
,
(
done
)
=>
{
initializeManager
();
tokensContainer
.
innerHTML
=
FilteredSearchSpecHelper
.
createTokensContainerHTML
(
`
${
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
label
'
,
'
=
'
,
'
~bug
'
)}
${
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
label
'
,
'
=
'
,
'
~bug
'
)}
`
);
visitUrl
.
mockImplementation
(
url
=>
{
visitUrl
.
mockImplementation
(
(
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}
&label_name[]=bug`
);
done
();
});
...
...
@@ -605,7 +605,7 @@ describe('Filtered Search Manager', () => {
it
(
'
correctly modifies params when custom modifier is passed
'
,
()
=>
{
const
modifedParams
=
manager
.
getAllParams
.
call
(
{
modifyUrlParams
:
params
=>
params
.
reverse
(),
modifyUrlParams
:
(
params
)
=>
params
.
reverse
(),
},
[].
concat
(
paramsArr
),
);
...
...
spec/frontend/filtered_search/filtered_search_token_keys_spec.js
View file @
b6a8d9ba
...
...
@@ -33,7 +33,7 @@ describe('Filtered Search Token Keys', () => {
describe
(
'
getKeys
'
,
()
=>
{
it
(
'
should return keys
'
,
()
=>
{
const
getKeys
=
new
FilteredSearchTokenKeys
(
tokenKeys
).
getKeys
();
const
keys
=
new
FilteredSearchTokenKeys
(
tokenKeys
).
get
().
map
(
i
=>
i
.
key
);
const
keys
=
new
FilteredSearchTokenKeys
(
tokenKeys
).
get
().
map
(
(
i
)
=>
i
.
key
);
keys
.
forEach
((
key
,
i
)
=>
{
expect
(
key
).
toEqual
(
getKeys
[
i
]);
...
...
spec/frontend/filtered_search/filtered_search_visual_tokens_spec.js
View file @
b6a8d9ba
...
...
@@ -7,7 +7,7 @@ describe('Filtered Search Visual Tokens', () => {
let
mock
;
const
subject
=
FilteredSearchVisualTokens
;
const
findElements
=
tokenElement
=>
{
const
findElements
=
(
tokenElement
)
=>
{
const
tokenNameElement
=
tokenElement
.
querySelector
(
'
.name
'
);
const
tokenOperatorElement
=
tokenElement
.
querySelector
(
'
.operator
'
);
const
tokenValueContainer
=
tokenElement
.
querySelector
(
'
.value-container
'
);
...
...
spec/frontend/filtered_search/issues_filtered_search_token_keys_spec.js
View file @
b6a8d9ba
...
...
@@ -23,7 +23,7 @@ describe('Issues Filtered Search Token Keys', () => {
});
it
(
'
should return assignee as a string
'
,
()
=>
{
const
assignee
=
tokenKeys
.
find
(
tokenKey
=>
tokenKey
.
key
===
'
assignee
'
);
const
assignee
=
tokenKeys
.
find
(
(
tokenKey
)
=>
tokenKey
.
key
===
'
assignee
'
);
expect
(
assignee
.
type
).
toEqual
(
'
string
'
);
});
...
...
@@ -32,7 +32,7 @@ describe('Issues Filtered Search Token Keys', () => {
describe
(
'
getKeys
'
,
()
=>
{
it
(
'
should return keys
'
,
()
=>
{
const
getKeys
=
IssuableFilteredSearchTokenKeys
.
getKeys
();
const
keys
=
IssuableFilteredSearchTokenKeys
.
get
().
map
(
i
=>
i
.
key
);
const
keys
=
IssuableFilteredSearchTokenKeys
.
get
().
map
(
(
i
)
=>
i
.
key
);
keys
.
forEach
((
key
,
i
)
=>
{
expect
(
key
).
toEqual
(
getKeys
[
i
]);
...
...
spec/frontend/filtered_search/recent_searches_root_spec.js
View file @
b6a8d9ba
...
...
@@ -16,7 +16,7 @@ describe('RecentSearchesRoot', () => {
},
};
Vue
.
mockImplementation
(
options
=>
{
Vue
.
mockImplementation
(
(
options
)
=>
{
({
data
,
template
}
=
options
);
});
...
...
spec/frontend/filtered_search/services/recent_searches_service_spec.js
View file @
b6a8d9ba
...
...
@@ -18,49 +18,49 @@ describe('RecentSearchesService', () => {
jest
.
spyOn
(
RecentSearchesService
,
'
isAvailable
'
).
mockReturnValue
(
true
);
});
it
(
'
should default to empty array
'
,
done
=>
{
it
(
'
should default to empty array
'
,
(
done
)
=>
{
const
fetchItemsPromise
=
service
.
fetch
();
fetchItemsPromise
.
then
(
items
=>
{
.
then
(
(
items
)
=>
{
expect
(
items
).
toEqual
([]);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
should reject when unable to parse
'
,
done
=>
{
it
(
'
should reject when unable to parse
'
,
(
done
)
=>
{
jest
.
spyOn
(
localStorage
,
'
getItem
'
).
mockReturnValue
(
'
fail
'
);
const
fetchItemsPromise
=
service
.
fetch
();
fetchItemsPromise
.
then
(
done
.
fail
)
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
expect
(
error
).
toEqual
(
expect
.
any
(
SyntaxError
));
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
should reject when service is unavailable
'
,
done
=>
{
it
(
'
should reject when service is unavailable
'
,
(
done
)
=>
{
RecentSearchesService
.
isAvailable
.
mockReturnValue
(
false
);
service
.
fetch
()
.
then
(
done
.
fail
)
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
expect
(
error
).
toEqual
(
expect
.
any
(
Error
));
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
should return items from localStorage
'
,
done
=>
{
it
(
'
should return items from localStorage
'
,
(
done
)
=>
{
jest
.
spyOn
(
localStorage
,
'
getItem
'
).
mockReturnValue
(
'
["foo", "bar"]
'
);
const
fetchItemsPromise
=
service
.
fetch
();
fetchItemsPromise
.
then
(
items
=>
{
.
then
(
(
items
)
=>
{
expect
(
items
).
toEqual
([
'
foo
'
,
'
bar
'
]);
})
.
then
(
done
)
...
...
@@ -74,11 +74,11 @@ describe('RecentSearchesService', () => {
jest
.
spyOn
(
Storage
.
prototype
,
'
getItem
'
).
mockImplementation
(()
=>
{});
});
it
(
'
should not call .getItem
'
,
done
=>
{
it
(
'
should not call .getItem
'
,
(
done
)
=>
{
RecentSearchesService
.
prototype
.
fetch
()
.
then
(
done
.
fail
)
.
catch
(
err
=>
{
.
catch
(
(
err
)
=>
{
expect
(
err
).
toEqual
(
new
RecentSearchesServiceError
());
expect
(
localStorage
.
getItem
).
not
.
toHaveBeenCalled
();
})
...
...
spec/frontend/filtered_search/visual_token_value_spec.js
View file @
b6a8d9ba
...
...
@@ -7,7 +7,7 @@ import DropdownUtils from '~/filtered_search//dropdown_utils';
import
FilteredSearchSpecHelper
from
'
../helpers/filtered_search_spec_helper
'
;
describe
(
'
Filtered Search Visual Tokens
'
,
()
=>
{
const
findElements
=
tokenElement
=>
{
const
findElements
=
(
tokenElement
)
=>
{
const
tokenNameElement
=
tokenElement
.
querySelector
(
'
.name
'
);
const
tokenValueContainer
=
tokenElement
.
querySelector
(
'
.value-container
'
);
const
tokenValueElement
=
tokenValueContainer
.
querySelector
(
'
.value
'
);
...
...
@@ -39,15 +39,15 @@ describe('Filtered Search Visual Tokens', () => {
let
usersCacheSpy
;
beforeEach
(()
=>
{
jest
.
spyOn
(
UsersCache
,
'
retrieve
'
).
mockImplementation
(
username
=>
usersCacheSpy
(
username
));
jest
.
spyOn
(
UsersCache
,
'
retrieve
'
).
mockImplementation
(
(
username
)
=>
usersCacheSpy
(
username
));
});
it
(
'
ignores error if UsersCache throws
'
,
done
=>
{
it
(
'
ignores error if UsersCache throws
'
,
(
done
)
=>
{
jest
.
spyOn
(
window
,
'
Flash
'
).
mockImplementation
(()
=>
{});
const
dummyError
=
new
Error
(
'
Earth rotated backwards
'
);
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
authorToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
usersCacheSpy
=
username
=>
{
usersCacheSpy
=
(
username
)
=>
{
expect
(
`@
${
username
}
`
).
toBe
(
tokenValue
);
return
Promise
.
reject
(
dummyError
);
};
...
...
@@ -61,10 +61,10 @@ describe('Filtered Search Visual Tokens', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does nothing if user cannot be found
'
,
done
=>
{
it
(
'
does nothing if user cannot be found
'
,
(
done
)
=>
{
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
authorToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
usersCacheSpy
=
username
=>
{
usersCacheSpy
=
(
username
)
=>
{
expect
(
`@
${
username
}
`
).
toBe
(
tokenValue
);
return
Promise
.
resolve
(
undefined
);
};
...
...
@@ -78,14 +78,14 @@ describe('Filtered Search Visual Tokens', () => {
.
catch
(
done
.
fail
);
});
it
(
'
replaces author token with avatar and display name
'
,
done
=>
{
it
(
'
replaces author token with avatar and display name
'
,
(
done
)
=>
{
const
dummyUser
=
{
name
:
'
Important Person
'
,
avatar_url
:
'
https://host.invalid/mypics/avatar.png
'
,
};
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
authorToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
usersCacheSpy
=
username
=>
{
usersCacheSpy
=
(
username
)
=>
{
expect
(
`@
${
username
}
`
).
toBe
(
tokenValue
);
return
Promise
.
resolve
(
dummyUser
);
};
...
...
@@ -104,14 +104,14 @@ describe('Filtered Search Visual Tokens', () => {
.
catch
(
done
.
fail
);
});
it
(
'
escapes user name when creating token
'
,
done
=>
{
it
(
'
escapes user name when creating token
'
,
(
done
)
=>
{
const
dummyUser
=
{
name
:
'
<script>
'
,
avatar_url
:
`
${
TEST_HOST
}
/mypics/avatar.png`
,
};
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
authorToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
usersCacheSpy
=
username
=>
{
usersCacheSpy
=
(
username
)
=>
{
expect
(
`@
${
username
}
`
).
toBe
(
tokenValue
);
return
Promise
.
resolve
(
dummyUser
);
};
...
...
@@ -168,7 +168,7 @@ describe('Filtered Search Visual Tokens', () => {
AjaxCache
.
internalStorage
[
`
${
filteredSearchInput
.
dataset
.
labelsEndpoint
}
.json`
]
=
labelData
;
});
const
parseColor
=
color
=>
{
const
parseColor
=
(
color
)
=>
{
const
dummyElement
=
document
.
createElement
(
'
div
'
);
dummyElement
.
style
.
color
=
color
;
return
dummyElement
.
style
.
color
;
...
...
@@ -180,10 +180,10 @@ describe('Filtered Search Visual Tokens', () => {
expect
(
tokenValueContainer
.
style
.
color
).
toBe
(
parseColor
(
label
.
text_color
));
};
const
findLabel
=
tokenValue
=>
labelData
.
find
(
label
=>
tokenValue
===
`~
${
DropdownUtils
.
getEscapedText
(
label
.
title
)}
`
);
const
findLabel
=
(
tokenValue
)
=>
labelData
.
find
(
(
label
)
=>
tokenValue
===
`~
${
DropdownUtils
.
getEscapedText
(
label
.
title
)}
`
);
it
(
'
updates the color of a label token
'
,
done
=>
{
it
(
'
updates the color of a label token
'
,
(
done
)
=>
{
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
bugLabelToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
const
matchingLabel
=
findLabel
(
tokenValue
);
...
...
@@ -197,7 +197,7 @@ describe('Filtered Search Visual Tokens', () => {
.
catch
(
done
.
fail
);
});
it
(
'
updates the color of a label token with spaces
'
,
done
=>
{
it
(
'
updates the color of a label token with spaces
'
,
(
done
)
=>
{
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
spaceLabelToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
const
matchingLabel
=
findLabel
(
tokenValue
);
...
...
@@ -211,7 +211,7 @@ describe('Filtered Search Visual Tokens', () => {
.
catch
(
done
.
fail
);
});
it
(
'
does not change color of a missing label
'
,
done
=>
{
it
(
'
does not change color of a missing label
'
,
(
done
)
=>
{
const
{
subject
,
tokenValueContainer
,
tokenValueElement
}
=
findElements
(
missingLabelToken
);
const
tokenValue
=
tokenValueElement
.
innerText
;
const
matchingLabel
=
findLabel
(
tokenValue
);
...
...
@@ -260,7 +260,7 @@ describe('Filtered Search Visual Tokens', () => {
});
describe
(
'
render
'
,
()
=>
{
const
setupSpies
=
subject
=>
{
const
setupSpies
=
(
subject
)
=>
{
jest
.
spyOn
(
subject
,
'
updateLabelTokenColor
'
).
mockImplementation
(()
=>
{});
const
updateLabelTokenColorSpy
=
subject
.
updateLabelTokenColor
;
...
...
spec/frontend/flash_spec.js
View file @
b6a8d9ba
...
...
@@ -325,7 +325,7 @@ describe('Flash', () => {
`
;
});
it
(
'
removes global flash on click
'
,
done
=>
{
it
(
'
removes global flash on click
'
,
(
done
)
=>
{
const
flashEl
=
document
.
querySelector
(
'
.flash
'
);
removeFlashClickListener
(
flashEl
,
false
);
...
...
spec/frontend/frequent_items/components/app_spec.js
View file @
b6a8d9ba
...
...
@@ -65,7 +65,7 @@ describe('Frequent Items App Component', () => {
storage
[
storageKey
]
=
value
;
});
localStorage
.
getItem
.
mockImplementation
(
storageKey
=>
{
localStorage
.
getItem
.
mockImplementation
(
(
storageKey
)
=>
{
if
(
storage
[
storageKey
])
{
return
storage
[
storageKey
];
}
...
...
@@ -160,7 +160,7 @@ describe('Frequent Items App Component', () => {
});
describe
(
'
created
'
,
()
=>
{
it
(
'
should bind event listeners on eventHub
'
,
done
=>
{
it
(
'
should bind event listeners on eventHub
'
,
(
done
)
=>
{
jest
.
spyOn
(
eventHub
,
'
$on
'
).
mockImplementation
(()
=>
{});
createComponentWithStore
().
$mount
();
...
...
@@ -173,7 +173,7 @@ describe('Frequent Items App Component', () => {
});
describe
(
'
beforeDestroy
'
,
()
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
done
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
(
done
)
=>
{
jest
.
spyOn
(
eventHub
,
'
$off
'
).
mockImplementation
(()
=>
{});
vm
.
$mount
();
...
...
@@ -191,7 +191,7 @@ describe('Frequent Items App Component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.search-input-container
'
)).
toBeDefined
();
});
it
(
'
should render loading animation
'
,
done
=>
{
it
(
'
should render loading animation
'
,
(
done
)
=>
{
vm
.
$store
.
dispatch
(
'
fetchSearchedItems
'
);
Vue
.
nextTick
(()
=>
{
...
...
@@ -204,7 +204,7 @@ describe('Frequent Items App Component', () => {
});
});
it
(
'
should render frequent projects list header
'
,
done
=>
{
it
(
'
should render frequent projects list header
'
,
(
done
)
=>
{
Vue
.
nextTick
(()
=>
{
const
sectionHeaderEl
=
vm
.
$el
.
querySelector
(
'
.section-header
'
);
...
...
@@ -214,7 +214,7 @@ describe('Frequent Items App Component', () => {
});
});
it
(
'
should render frequent projects list
'
,
done
=>
{
it
(
'
should render frequent projects list
'
,
(
done
)
=>
{
const
expectedResult
=
getTopFrequentItems
(
mockFrequentProjects
);
localStorage
.
getItem
.
mockImplementation
(()
=>
JSON
.
stringify
(
mockFrequentProjects
));
...
...
@@ -229,7 +229,7 @@ describe('Frequent Items App Component', () => {
});
});
it
(
'
should render searched projects list
'
,
done
=>
{
it
(
'
should render searched projects list
'
,
(
done
)
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects.json
(
.*
)
$/
).
replyOnce
(
200
,
mockSearchedProjects
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.frequent-items-list-container li
'
).
length
).
toBe
(
1
);
...
...
spec/frontend/frequent_items/components/frequent_items_list_item_spec.js
View file @
b6a8d9ba
...
...
@@ -114,7 +114,7 @@ describe('FrequentItemsListItemComponent', () => {
const
link
=
wrapper
.
find
(
'
a
'
);
// NOTE: this listener is required to prevent the click from going through and causing:
// `Error: Not implemented: navigation ...`
link
.
element
.
addEventListener
(
'
click
'
,
e
=>
{
link
.
element
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
e
.
preventDefault
();
});
link
.
trigger
(
'
click
'
);
...
...
spec/frontend/frequent_items/components/frequent_items_search_input_spec.js
View file @
b6a8d9ba
...
...
@@ -46,7 +46,7 @@ describe('FrequentItemsSearchInputComponent', () => {
});
describe
(
'
mounted
'
,
()
=>
{
it
(
'
should listen `dropdownOpen` event
'
,
done
=>
{
it
(
'
should listen `dropdownOpen` event
'
,
(
done
)
=>
{
jest
.
spyOn
(
eventHub
,
'
$on
'
).
mockImplementation
(()
=>
{});
const
vmX
=
createComponent
().
vm
;
...
...
@@ -61,7 +61,7 @@ describe('FrequentItemsSearchInputComponent', () => {
});
describe
(
'
beforeDestroy
'
,
()
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
done
=>
{
it
(
'
should unbind event listeners on eventHub
'
,
(
done
)
=>
{
const
vmX
=
createComponent
().
vm
;
jest
.
spyOn
(
eventHub
,
'
$off
'
).
mockImplementation
(()
=>
{});
...
...
spec/frontend/frequent_items/store/actions_spec.js
View file @
b6a8d9ba
...
...
@@ -29,7 +29,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
setNamespace
'
,
()
=>
{
it
(
'
should set namespace
'
,
done
=>
{
it
(
'
should set namespace
'
,
(
done
)
=>
{
testAction
(
actions
.
setNamespace
,
mockNamespace
,
...
...
@@ -42,7 +42,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
setStorageKey
'
,
()
=>
{
it
(
'
should set storage key
'
,
done
=>
{
it
(
'
should set storage key
'
,
(
done
)
=>
{
testAction
(
actions
.
setStorageKey
,
mockStorageKey
,
...
...
@@ -55,7 +55,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
requestFrequentItems
'
,
()
=>
{
it
(
'
should request frequent items
'
,
done
=>
{
it
(
'
should request frequent items
'
,
(
done
)
=>
{
testAction
(
actions
.
requestFrequentItems
,
null
,
...
...
@@ -68,7 +68,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
receiveFrequentItemsSuccess
'
,
()
=>
{
it
(
'
should set frequent items
'
,
done
=>
{
it
(
'
should set frequent items
'
,
(
done
)
=>
{
testAction
(
actions
.
receiveFrequentItemsSuccess
,
mockFrequentProjects
,
...
...
@@ -81,7 +81,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
receiveFrequentItemsError
'
,
()
=>
{
it
(
'
should set frequent items error state
'
,
done
=>
{
it
(
'
should set frequent items error state
'
,
(
done
)
=>
{
testAction
(
actions
.
receiveFrequentItemsError
,
null
,
...
...
@@ -94,7 +94,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
fetchFrequentItems
'
,
()
=>
{
it
(
'
should dispatch `receiveFrequentItemsSuccess`
'
,
done
=>
{
it
(
'
should dispatch `receiveFrequentItemsSuccess`
'
,
(
done
)
=>
{
mockedState
.
namespace
=
mockNamespace
;
mockedState
.
storageKey
=
mockStorageKey
;
...
...
@@ -108,7 +108,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
);
});
it
(
'
should dispatch `receiveFrequentItemsError`
'
,
done
=>
{
it
(
'
should dispatch `receiveFrequentItemsError`
'
,
(
done
)
=>
{
jest
.
spyOn
(
AccessorUtilities
,
'
isLocalStorageAccessSafe
'
).
mockReturnValue
(
false
);
mockedState
.
namespace
=
mockNamespace
;
mockedState
.
storageKey
=
mockStorageKey
;
...
...
@@ -125,7 +125,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
requestSearchedItems
'
,
()
=>
{
it
(
'
should request searched items
'
,
done
=>
{
it
(
'
should request searched items
'
,
(
done
)
=>
{
testAction
(
actions
.
requestSearchedItems
,
null
,
...
...
@@ -138,7 +138,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
receiveSearchedItemsSuccess
'
,
()
=>
{
it
(
'
should set searched items
'
,
done
=>
{
it
(
'
should set searched items
'
,
(
done
)
=>
{
testAction
(
actions
.
receiveSearchedItemsSuccess
,
mockSearchedProjects
,
...
...
@@ -151,7 +151,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
receiveSearchedItemsError
'
,
()
=>
{
it
(
'
should set searched items error state
'
,
done
=>
{
it
(
'
should set searched items error state
'
,
(
done
)
=>
{
testAction
(
actions
.
receiveSearchedItemsError
,
null
,
...
...
@@ -168,7 +168,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
gon
.
api_version
=
'
v4
'
;
});
it
(
'
should dispatch `receiveSearchedItemsSuccess`
'
,
done
=>
{
it
(
'
should dispatch `receiveSearchedItemsSuccess`
'
,
(
done
)
=>
{
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects.json
(
.*
)
$/
).
replyOnce
(
200
,
mockSearchedProjects
,
{});
testAction
(
...
...
@@ -187,7 +187,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
);
});
it
(
'
should dispatch `receiveSearchedItemsError`
'
,
done
=>
{
it
(
'
should dispatch `receiveSearchedItemsError`
'
,
(
done
)
=>
{
gon
.
api_version
=
'
v4
'
;
mock
.
onGet
(
/
\/
api
\/
v4
\/
projects.json
(
.*
)
$/
).
replyOnce
(
500
);
...
...
@@ -203,7 +203,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
});
describe
(
'
setSearchQuery
'
,
()
=>
{
it
(
'
should commit query and dispatch `fetchSearchedItems` when query is present
'
,
done
=>
{
it
(
'
should commit query and dispatch `fetchSearchedItems` when query is present
'
,
(
done
)
=>
{
testAction
(
actions
.
setSearchQuery
,
{
query
:
'
test
'
},
...
...
@@ -214,7 +214,7 @@ describe('Frequent Items Dropdown Store Actions', () => {
);
});
it
(
'
should commit query and dispatch `fetchFrequentItems` when query is empty
'
,
done
=>
{
it
(
'
should commit query and dispatch `fetchFrequentItems` when query is empty
'
,
(
done
)
=>
{
testAction
(
actions
.
setSearchQuery
,
null
,
...
...
spec/frontend/gfm_auto_complete_spec.js
View file @
b6a8d9ba
...
...
@@ -164,7 +164,7 @@ describe('GfmAutoComplete', () => {
});
});
it
.
each
([
200
,
500
])(
'
should set the loading state
'
,
async
responseStatus
=>
{
it
.
each
([
200
,
500
])(
'
should set the loading state
'
,
async
(
responseStatus
)
=>
{
mock
.
onGet
(
'
vulnerabilities_autocomplete_url
'
).
replyOnce
(
responseStatus
);
fetchData
.
call
(
context
,
{},
'
[vulnerability:
'
,
'
query
'
);
...
...
@@ -371,9 +371,9 @@ describe('GfmAutoComplete', () => {
const
jointAllowedSymbols
=
allowedSymbols
.
join
(
''
);
describe
(
'
should match regular symbols
'
,
()
=>
{
flagsUseDefaultMatcher
.
forEach
(
flag
=>
{
allowedSymbols
.
forEach
(
symbol
=>
{
argumentSize
.
forEach
(
size
=>
{
flagsUseDefaultMatcher
.
forEach
(
(
flag
)
=>
{
allowedSymbols
.
forEach
(
(
symbol
)
=>
{
argumentSize
.
forEach
(
(
size
)
=>
{
const
query
=
new
Array
(
size
+
1
).
join
(
symbol
);
const
subtext
=
flag
+
query
;
...
...
@@ -395,8 +395,8 @@ describe('GfmAutoComplete', () => {
const
shouldNotBeFollowedBy
=
flags
.
concat
([
'
\
x00
'
,
'
\
x10
'
,
'
\
x3f
'
,
'
\n
'
,
'
'
]);
const
shouldNotBePrependedBy
=
[
'
`
'
];
flagsUseDefaultMatcher
.
forEach
(
atSign
=>
{
shouldNotBeFollowedBy
.
forEach
(
followedSymbol
=>
{
flagsUseDefaultMatcher
.
forEach
(
(
atSign
)
=>
{
shouldNotBeFollowedBy
.
forEach
(
(
followedSymbol
)
=>
{
const
seq
=
atSign
+
followedSymbol
;
it
(
`should not match
${
JSON
.
stringify
(
seq
)}
`
,
()
=>
{
...
...
@@ -404,7 +404,7 @@ describe('GfmAutoComplete', () => {
});
});
shouldNotBePrependedBy
.
forEach
(
prependedSymbol
=>
{
shouldNotBePrependedBy
.
forEach
(
(
prependedSymbol
)
=>
{
const
seq
=
prependedSymbol
+
atSign
;
it
(
`should not match "
${
seq
}
"`
,
()
=>
{
...
...
@@ -638,8 +638,8 @@ describe('GfmAutoComplete', () => {
};
const
allLabels
=
labelsFixture
;
const
assignedLabels
=
allLabels
.
filter
(
label
=>
label
.
set
);
const
unassignedLabels
=
allLabels
.
filter
(
label
=>
!
label
.
set
);
const
assignedLabels
=
allLabels
.
filter
(
(
label
)
=>
label
.
set
);
const
unassignedLabels
=
allLabels
.
filter
(
(
label
)
=>
!
label
.
set
);
let
autocomplete
;
let
$textarea
;
...
...
@@ -655,7 +655,7 @@ describe('GfmAutoComplete', () => {
autocomplete
.
destroy
();
});
const
triggerDropdown
=
text
=>
{
const
triggerDropdown
=
(
text
)
=>
{
$textarea
.
trigger
(
'
focus
'
).
val
(
text
).
caret
(
'
pos
'
,
-
1
);
$textarea
.
trigger
(
'
keyup
'
);
...
...
@@ -665,12 +665,12 @@ describe('GfmAutoComplete', () => {
const
getDropdownItems
=
()
=>
{
const
dropdown
=
document
.
getElementById
(
'
at-view-labels
'
);
const
items
=
dropdown
.
getElementsByTagName
(
'
li
'
);
return
[].
map
.
call
(
items
,
item
=>
item
.
textContent
.
trim
());
return
[].
map
.
call
(
items
,
(
item
)
=>
item
.
textContent
.
trim
());
};
const
expectLabels
=
({
input
,
output
})
=>
triggerDropdown
(
input
).
then
(()
=>
{
expect
(
getDropdownItems
()).
toEqual
(
output
.
map
(
label
=>
label
.
title
));
expect
(
getDropdownItems
()).
toEqual
(
output
.
map
(
(
label
)
=>
label
.
title
));
});
describe
(
'
with no labels assigned
'
,
()
=>
{
...
...
@@ -739,9 +739,9 @@ describe('GfmAutoComplete', () => {
});
describe.each`
name | inputFormat | assert
${'insertTemplateFunction'} | ${
name
=> ({ name })} | ${assertInserted}
${'templateFunction'} | ${
name
=> name} | ${assertTemplated}
name | inputFormat
| assert
${'insertTemplateFunction'} | ${
(name)
=> ({ name })} | ${assertInserted}
${'templateFunction'} | ${
(name)
=> name} | ${assertTemplated}
`('Emoji.$name', ({ name, inputFormat, assert }) => {
const execute = (accessor, input, emoji) =>
assert({
...
...
@@ -808,7 +808,7 @@ describe('GfmAutoComplete', () => {
const item = GfmAutoComplete.Emoji.templateFunction('heart')
.replace(/(<gl-emoji)
\
s+(data-name)/, '$1 $2')
.replace(/>
\
s+|
\
s+</g,
s
=> s.trim());
.replace(/>
\
s+|
\
s+</g,
(s)
=> s.trim());
expect(item).toEqual(
`<li>${heart.name}<gl-emoji data-name=
"
$
{
heart
.
name
}
"></gl-emoji></li>`
,
);
...
...
@@ -820,7 +820,7 @@ describe('GfmAutoComplete', () => {
const
item
=
GfmAutoComplete
.
Emoji
.
templateFunction
(
'
star
'
)
.
replace
(
/
(
<gl-emoji
)\s
+
(
data-name
)
/
,
'
$1 $2
'
)
.
replace
(
/>
\s
+|
\s
+</g
,
s
=>
s
.
trim
());
.
replace
(
/>
\s
+|
\s
+</g
,
(
s
)
=>
s
.
trim
());
expect
(
item
).
toEqual
(
`<li>
${
star
.
name
}
<gl-emoji data-name="
${
star
.
name
}
"></gl-emoji></li>`
);
});
});
...
...
spec/frontend/gl_field_errors_spec.js
View file @
b6a8d9ba
...
...
@@ -33,7 +33,7 @@ describe('GL Style Field Errors', () => {
expect
(
customErrorElem
.
length
).
toBe
(
1
);
const
customErrors
=
testContext
.
fieldErrors
.
state
.
inputs
.
filter
(
input
=>
{
const
customErrors
=
testContext
.
fieldErrors
.
state
.
inputs
.
filter
(
(
input
)
=>
{
return
input
.
inputElement
.
hasClass
(
customErrorFlag
);
});
...
...
spec/frontend/gl_form_spec.js
View file @
b6a8d9ba
...
...
@@ -8,7 +8,7 @@ describe('GLForm', () => {
const
testContext
=
{};
describe
(
'
when instantiated
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
(
done
)
=>
{
window
.
gl
=
window
.
gl
||
{};
testContext
.
form
=
$
(
'
<form class="gfm-form"><textarea class="js-gfm-input"></form>
'
);
...
...
@@ -28,7 +28,7 @@ describe('GLForm', () => {
});
describe
(
'
setupAutosize
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
(
done
)
=>
{
testContext
.
glForm
.
setupAutosize
();
setImmediate
(()
=>
{
...
...
spec/frontend/gpg_badges_spec.js
View file @
b6a8d9ba
...
...
@@ -36,7 +36,7 @@ describe('GpgBadges', () => {
mock
.
restore
();
});
it
(
'
does not make a request if there is no container element
'
,
done
=>
{
it
(
'
does not make a request if there is no container element
'
,
(
done
)
=>
{
setFixtures
(
''
);
jest
.
spyOn
(
axios
,
'
get
'
).
mockImplementation
(()
=>
{});
...
...
@@ -48,13 +48,13 @@ describe('GpgBadges', () => {
.
catch
(
done
.
fail
);
});
it
(
'
throws an error if the endpoint is missing
'
,
done
=>
{
it
(
'
throws an error if the endpoint is missing
'
,
(
done
)
=>
{
setFixtures
(
'
<div class="js-signature-container"></div>
'
);
jest
.
spyOn
(
axios
,
'
get
'
).
mockImplementation
(()
=>
{});
GpgBadges
.
fetch
()
.
then
(()
=>
done
.
fail
(
'
Expected error to be thrown
'
))
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
expect
(
error
.
message
).
toBe
(
'
Missing commit signatures endpoint!
'
);
expect
(
axios
.
get
).
not
.
toHaveBeenCalled
();
})
...
...
@@ -62,7 +62,7 @@ describe('GpgBadges', () => {
.
catch
(
done
.
fail
);
});
it
(
'
displays a loading spinner
'
,
done
=>
{
it
(
'
displays a loading spinner
'
,
(
done
)
=>
{
mock
.
onGet
(
dummyUrl
).
replyOnce
(
200
);
GpgBadges
.
fetch
()
...
...
@@ -76,7 +76,7 @@ describe('GpgBadges', () => {
.
catch
(
done
.
fail
);
});
it
(
'
replaces the loading spinner
'
,
done
=>
{
it
(
'
replaces the loading spinner
'
,
(
done
)
=>
{
mock
.
onGet
(
dummyUrl
).
replyOnce
(
200
,
dummyResponse
);
GpgBadges
.
fetch
()
...
...
spec/frontend/group_settings/components/shared_runners_form_spec.js
View file @
b6a8d9ba
...
...
@@ -32,7 +32,7 @@ describe('group_settings/components/shared_runners_form', () => {
const
findErrorAlert
=
()
=>
wrapper
.
find
(
GlAlert
);
const
findEnabledToggle
=
()
=>
wrapper
.
find
(
'
[data-testid="enable-runners-toggle"]
'
);
const
findOverrideToggle
=
()
=>
wrapper
.
find
(
'
[data-testid="override-runners-toggle"]
'
);
const
changeToggle
=
toggle
=>
toggle
.
vm
.
$emit
(
'
change
'
,
!
toggle
.
props
(
'
value
'
));
const
changeToggle
=
(
toggle
)
=>
toggle
.
vm
.
$emit
(
'
change
'
,
!
toggle
.
props
(
'
value
'
));
const
getRequestPayload
=
()
=>
JSON
.
parse
(
mock
.
history
.
put
[
0
].
data
);
const
isLoadingIconVisible
=
()
=>
findLoadingIcon
().
exists
();
...
...
spec/frontend/groups/components/group_item_spec.js
View file @
b6a8d9ba
...
...
@@ -31,7 +31,7 @@ describe('GroupItemComponent', () => {
vm
.
$destroy
();
});
const
withMicrodata
=
group
=>
({
const
withMicrodata
=
(
group
)
=>
({
...
group
,
microdata
:
getGroupItemMicrodata
(
group
),
});
...
...
@@ -49,7 +49,7 @@ describe('GroupItemComponent', () => {
const
{
rowClass
}
=
vm
;
expect
(
Object
.
keys
(
rowClass
).
length
).
toBe
(
classes
.
length
);
Object
.
keys
(
rowClass
).
forEach
(
className
=>
{
Object
.
keys
(
rowClass
).
forEach
(
(
className
)
=>
{
expect
(
classes
.
indexOf
(
className
)).
toBeGreaterThan
(
-
1
);
});
});
...
...
@@ -220,13 +220,13 @@ describe('GroupItemComponent', () => {
});
describe
(
'
schema.org props
'
,
()
=>
{
describe
(
'
when showSchemaMarkup is disabled on the group
'
,
()
=>
{
it
.
each
([
'
itemprop
'
,
'
itemtype
'
,
'
itemscope
'
],
'
it does not set %s
'
,
attr
=>
{
it
.
each
([
'
itemprop
'
,
'
itemtype
'
,
'
itemscope
'
],
'
it does not set %s
'
,
(
attr
)
=>
{
expect
(
vm
.
$el
.
getAttribute
(
attr
)).
toBeNull
();
});
it
.
each
(
[
'
.js-group-avatar
'
,
'
.js-group-name
'
,
'
.js-group-description
'
],
'
it does not set `itemprop` on sub-nodes
'
,
selector
=>
{
(
selector
)
=>
{
expect
(
vm
.
$el
.
querySelector
(
selector
).
getAttribute
(
'
itemprop
'
)).
toBeNull
();
},
);
...
...
spec/frontend/groups/components/visibility_level_dropdown_spec.js
View file @
b6a8d9ba
...
...
@@ -11,7 +11,7 @@ describe('Visibility Level Dropdown', () => {
];
const
defaultLevel
=
0
;
const
createComponent
=
propsData
=>
{
const
createComponent
=
(
propsData
)
=>
{
wrapper
=
shallowMount
(
Component
,
{
propsData
,
});
...
...
@@ -33,7 +33,7 @@ describe('Visibility Level Dropdown', () => {
wrapper
.
find
(
"
input[name='group[visibility_level]']
"
).
attributes
(
'
value
'
);
const
dropdownText
=
()
=>
wrapper
.
find
(
GlDropdown
).
props
(
'
text
'
);
const
findDropdownItems
=
()
=>
wrapper
.
findAll
(
GlDropdownItem
).
wrappers
.
map
(
option
=>
({
wrapper
.
findAll
(
GlDropdownItem
).
wrappers
.
map
(
(
option
)
=>
({
text
:
option
.
text
(),
secondaryText
:
option
.
props
(
'
secondaryText
'
),
}));
...
...
spec/frontend/helpers/backoff_helper.js
View file @
b6a8d9ba
...
...
@@ -16,9 +16,9 @@
*
* @param {Function} callback
*/
export
const
backoffMockImplementation
=
callback
=>
{
export
const
backoffMockImplementation
=
(
callback
)
=>
{
const
q
=
new
Promise
((
resolve
,
reject
)
=>
{
const
stop
=
arg
=>
(
arg
instanceof
Error
?
reject
(
arg
)
:
resolve
(
arg
));
const
stop
=
(
arg
)
=>
(
arg
instanceof
Error
?
reject
(
arg
)
:
resolve
(
arg
));
const
next
=
()
=>
callback
(
next
,
stop
);
// Define a timeout based on a mock timer
setTimeout
(()
=>
{
...
...
spec/frontend/helpers/dom_events_helper.js
View file @
b6a8d9ba
export
const
triggerDOMEvent
=
type
=>
{
export
const
triggerDOMEvent
=
(
type
)
=>
{
window
.
document
.
dispatchEvent
(
new
Event
(
type
,
{
bubbles
:
true
,
...
...
spec/frontend/helpers/dom_shims/size_properties.js
View file @
b6a8d9ba
const
convertFromStyle
=
style
=>
{
const
convertFromStyle
=
(
style
)
=>
{
if
(
style
.
match
(
/
[
0-9
](
px|rem
)
/g
))
{
return
Number
(
style
.
replace
(
/
[^
0-9
]
/g
,
''
));
}
...
...
spec/frontend/helpers/emoji.js
View file @
b6a8d9ba
...
...
@@ -55,7 +55,7 @@ export const emojiFixtureMap = {
},
};
Object
.
keys
(
emojiFixtureMap
).
forEach
(
k
=>
{
Object
.
keys
(
emojiFixtureMap
).
forEach
(
(
k
)
=>
{
emojiFixtureMap
[
k
].
name
=
k
;
if
(
!
emojiFixtureMap
[
k
].
aliases
)
{
emojiFixtureMap
[
k
].
aliases
=
[];
...
...
@@ -64,7 +64,7 @@ Object.keys(emojiFixtureMap).forEach(k => {
export
async
function
initEmojiMock
()
{
const
emojiData
=
Object
.
fromEntries
(
Object
.
values
(
emojiFixtureMap
).
map
(
m
=>
{
Object
.
values
(
emojiFixtureMap
).
map
(
(
m
)
=>
{
const
{
name
:
n
,
moji
:
e
,
unicodeVersion
:
u
,
category
:
c
,
description
:
d
}
=
m
;
return
[
n
,
{
c
,
e
,
d
,
u
}];
}),
...
...
@@ -81,8 +81,8 @@ export async function initEmojiMock() {
export
function
describeEmojiFields
(
label
,
tests
)
{
describe
.
each
`
field | accessor
${
'
name
'
}
|
${
e
=>
e
.
name
}
${
'
alias
'
}
|
${
e
=>
e
.
aliases
[
0
]}
${
'
description
'
}
|
${
e
=>
e
.
description
}
${
'
name
'
}
|
${
(
e
)
=>
e
.
name
}
${
'
alias
'
}
|
${
(
e
)
=>
e
.
aliases
[
0
]}
${
'
description
'
}
|
${
(
e
)
=>
e
.
description
}
`
(
label
,
tests
);
}
spec/frontend/helpers/event_hub_factory_spec.js
View file @
b6a8d9ba
...
...
@@ -93,7 +93,7 @@ describe('event bus factory', () => {
describe
(
'
$off
'
,
()
=>
{
beforeEach
(()
=>
{
otherHandlers
.
forEach
(
x
=>
eventBus
.
$on
(
TEST_EVENT
,
x
));
otherHandlers
.
forEach
(
(
x
)
=>
eventBus
.
$on
(
TEST_EVENT
,
x
));
eventBus
.
$on
(
TEST_EVENT
,
handler
);
});
...
...
@@ -115,7 +115,7 @@ describe('event bus factory', () => {
eventBus
.
$emit
(
TEST_EVENT
);
expect
(
handler
).
not
.
toHaveBeenCalled
();
expect
(
otherHandlers
.
map
(
x
=>
x
.
mock
.
calls
.
length
)).
toEqual
(
otherHandlers
.
map
(()
=>
1
));
expect
(
otherHandlers
.
map
(
(
x
)
=>
x
.
mock
.
calls
.
length
)).
toEqual
(
otherHandlers
.
map
(()
=>
1
));
});
it
(
'
without a handler, will no longer call any handlers
'
,
()
=>
{
...
...
@@ -124,13 +124,13 @@ describe('event bus factory', () => {
eventBus
.
$emit
(
TEST_EVENT
);
expect
(
handler
).
not
.
toHaveBeenCalled
();
expect
(
otherHandlers
.
map
(
x
=>
x
.
mock
.
calls
.
length
)).
toEqual
(
otherHandlers
.
map
(()
=>
0
));
expect
(
otherHandlers
.
map
(
(
x
)
=>
x
.
mock
.
calls
.
length
)).
toEqual
(
otherHandlers
.
map
(()
=>
0
));
});
});
describe
(
'
$emit
'
,
()
=>
{
beforeEach
(()
=>
{
otherHandlers
.
forEach
(
x
=>
eventBus
.
$on
(
TEST_EVENT_2
,
x
));
otherHandlers
.
forEach
(
(
x
)
=>
eventBus
.
$on
(
TEST_EVENT_2
,
x
));
eventBus
.
$on
(
TEST_EVENT
,
handler
);
});
...
...
@@ -138,7 +138,7 @@ describe('event bus factory', () => {
eventBus
.
$emit
(
TEST_EVENT
,
'
arg1
'
);
expect
(
handler
).
toHaveBeenCalledWith
(
'
arg1
'
);
expect
(
otherHandlers
.
map
(
x
=>
x
.
mock
.
calls
.
length
)).
toEqual
(
otherHandlers
.
map
(()
=>
0
));
expect
(
otherHandlers
.
map
(
(
x
)
=>
x
.
mock
.
calls
.
length
)).
toEqual
(
otherHandlers
.
map
(()
=>
0
));
});
});
});
spec/frontend/helpers/fake_date.js
View file @
b6a8d9ba
...
...
@@ -3,9 +3,9 @@ export const DEFAULT_ARGS = [2020, 6, 6];
const
RealDate
=
Date
;
const
isMocked
=
val
=>
Boolean
(
val
.
mock
);
const
isMocked
=
(
val
)
=>
Boolean
(
val
.
mock
);
export
const
createFakeDateClass
=
ctorDefault
=>
{
export
const
createFakeDateClass
=
(
ctorDefault
)
=>
{
const
FakeDate
=
new
Proxy
(
RealDate
,
{
construct
:
(
target
,
argArray
)
=>
{
const
ctorArgs
=
argArray
.
length
?
argArray
:
ctorDefault
;
...
...
@@ -25,7 +25,7 @@ export const createFakeDateClass = ctorDefault => {
return
target
[
prop
];
},
getPrototypeOf
:
target
=>
{
getPrototypeOf
:
(
target
)
=>
{
return
target
.
prototype
;
},
// We need to be able to set props so that `jest.spyOn` will work.
...
...
spec/frontend/helpers/fake_request_animation_frame.js
View file @
b6a8d9ba
...
...
@@ -3,7 +3,7 @@ export const useFakeRequestAnimationFrame = () => {
beforeEach
(()
=>
{
orig
=
global
.
requestAnimationFrame
;
global
.
requestAnimationFrame
=
cb
=>
cb
();
global
.
requestAnimationFrame
=
(
cb
)
=>
cb
();
});
afterEach
(()
=>
{
...
...
spec/frontend/helpers/fixtures.js
View file @
b6a8d9ba
...
...
@@ -20,7 +20,7 @@ Did you run bin/rake frontend:fixtures?`,
return
fs
.
readFileSync
(
absolutePath
,
'
utf8
'
);
}
export
const
getJSONFixture
=
relativePath
=>
JSON
.
parse
(
getFixture
(
relativePath
));
export
const
getJSONFixture
=
(
relativePath
)
=>
JSON
.
parse
(
getFixture
(
relativePath
));
export
const
resetHTMLFixture
=
()
=>
{
document
.
head
.
innerHTML
=
''
;
...
...
spec/frontend/helpers/jest_helpers.js
View file @
b6a8d9ba
...
...
@@ -15,7 +15,7 @@ Try not to use these in new tests - this module is provided primarily for conven
*/
export
function
createSpyObj
(
baseName
,
methods
)
{
const
obj
=
{};
methods
.
forEach
(
method
=>
{
methods
.
forEach
(
(
method
)
=>
{
obj
[
method
]
=
jest
.
fn
().
mockName
(
`
${
baseName
}
#
${
method
}
`
);
});
return
obj
;
...
...
spec/frontend/helpers/local_storage_helper.js
View file @
b6a8d9ba
...
...
@@ -8,7 +8,7 @@
*
* @param {() => any} fn Function that returns the object to use for localStorage
*/
const
useLocalStorage
=
fn
=>
{
const
useLocalStorage
=
(
fn
)
=>
{
const
origLocalStorage
=
window
.
localStorage
;
let
currentLocalStorage
=
origLocalStorage
;
...
...
@@ -35,11 +35,11 @@ export const createLocalStorageSpy = () => {
clear
:
jest
.
fn
(()
=>
{
storage
=
{};
}),
getItem
:
jest
.
fn
(
key
=>
(
key
in
storage
?
storage
[
key
]
:
null
)),
getItem
:
jest
.
fn
(
(
key
)
=>
(
key
in
storage
?
storage
[
key
]
:
null
)),
setItem
:
jest
.
fn
((
key
,
value
)
=>
{
storage
[
key
]
=
value
;
}),
removeItem
:
jest
.
fn
(
key
=>
delete
storage
[
key
]),
removeItem
:
jest
.
fn
(
(
key
)
=>
delete
storage
[
key
]),
};
};
...
...
spec/frontend/helpers/locale_helper.js
View file @
b6a8d9ba
export
const
setLanguage
=
languageCode
=>
{
export
const
setLanguage
=
(
languageCode
)
=>
{
const
htmlElement
=
document
.
querySelector
(
'
html
'
);
if
(
languageCode
)
{
...
...
spec/frontend/helpers/mock_window_location_helper.js
View file @
b6a8d9ba
...
...
@@ -8,7 +8,7 @@
*
* @param {() => any} fn Function that returns the object to use for window.location
*/
const
useMockLocation
=
fn
=>
{
const
useMockLocation
=
(
fn
)
=>
{
const
origWindowLocation
=
window
.
location
;
let
currentWindowLocation
;
...
...
spec/frontend/helpers/set_timeout_promise_helper.js
View file @
b6a8d9ba
export
default
(
time
=
0
)
=>
new
Promise
(
resolve
=>
{
new
Promise
(
(
resolve
)
=>
{
setTimeout
(
resolve
,
time
);
});
spec/frontend/helpers/set_window_location_helper_spec.js
View file @
b6a8d9ba
...
...
@@ -32,7 +32,7 @@ describe('setWindowLocation', () => {
it
.
each
([
null
,
1
,
undefined
,
false
,
''
,
'
gitlab.com
'
])(
'
throws an error when called with an invalid url: "%s"
'
,
invalidUrl
=>
{
(
invalidUrl
)
=>
{
expect
(()
=>
setWindowLocation
(
invalidUrl
)).
toThrow
(
/Invalid URL/
);
expect
(
window
.
location
).
toBe
(
originalLocation
);
},
...
...
spec/frontend/helpers/startup_css_helper_spec.js
View file @
b6a8d9ba
...
...
@@ -75,7 +75,7 @@ describe('waitForCSSLoaded', () => {
const
events
=
waitForCSSLoaded
(
mockedCallback
);
document
.
querySelectorAll
(
'
[data-startupcss="loading"]
'
)
.
forEach
(
elem
=>
elem
.
setAttribute
(
'
data-startupcss
'
,
'
loaded
'
));
.
forEach
(
(
elem
)
=>
elem
.
setAttribute
(
'
data-startupcss
'
,
'
loaded
'
));
document
.
dispatchEvent
(
new
CustomEvent
(
'
CSSStartupLinkLoaded
'
));
await
events
;
...
...
spec/frontend/helpers/stub_children.js
View file @
b6a8d9ba
export
default
function
stubChildren
(
Component
)
{
return
Object
.
fromEntries
(
Object
.
keys
(
Component
.
components
).
map
(
c
=>
[
c
,
true
]));
return
Object
.
fromEntries
(
Object
.
keys
(
Component
.
components
).
map
(
(
c
)
=>
[
c
,
true
]));
}
spec/frontend/helpers/text_helper.js
View file @
b6a8d9ba
...
...
@@ -2,17 +2,17 @@
* Replaces line break with an empty space
* @param {*} data
*/
export
const
removeBreakLine
=
data
=>
data
.
replace
(
/
\r?\n
|
\r
/g
,
'
'
);
export
const
removeBreakLine
=
(
data
)
=>
data
.
replace
(
/
\r?\n
|
\r
/g
,
'
'
);
/**
* Removes line breaks, spaces and trims the given text
* @param {String} str
* @returns {String}
*/
export
const
trimText
=
str
=>
export
const
trimText
=
(
str
)
=>
str
.
replace
(
/
\r?\n
|
\r
/g
,
''
)
.
replace
(
/
\s\s
+/g
,
'
'
)
.
trim
();
export
const
removeWhitespace
=
str
=>
str
.
replace
(
/
\s\s
+/g
,
'
'
);
export
const
removeWhitespace
=
(
str
)
=>
str
.
replace
(
/
\s\s
+/g
,
'
'
);
spec/frontend/helpers/timeout.js
View file @
b6a8d9ba
...
...
@@ -4,7 +4,7 @@ const IS_DEBUGGING = process.execArgv.join(' ').includes('--inspect-brk');
let
testTimeoutNS
;
export
const
setTestTimeout
=
newTimeoutMS
=>
{
export
const
setTestTimeout
=
(
newTimeoutMS
)
=>
{
const
newTimeoutNS
=
newTimeoutMS
*
NS_PER_MS
;
// never accept a smaller timeout than the default
if
(
newTimeoutNS
<
testTimeoutNS
)
{
...
...
@@ -18,7 +18,7 @@ export const setTestTimeout = newTimeoutMS => {
// Allows slow tests to set their own timeout.
// Useful for tests with jQuery, which is very slow in big DOMs.
let
temporaryTimeoutNS
=
null
;
export
const
setTestTimeoutOnce
=
newTimeoutMS
=>
{
export
const
setTestTimeoutOnce
=
(
newTimeoutMS
)
=>
{
const
newTimeoutNS
=
newTimeoutMS
*
NS_PER_MS
;
// never accept a smaller timeout than the default
if
(
newTimeoutNS
<
testTimeoutNS
)
{
...
...
@@ -28,7 +28,7 @@ export const setTestTimeoutOnce = newTimeoutMS => {
temporaryTimeoutNS
=
newTimeoutNS
;
};
export
const
initializeTestTimeout
=
defaultTimeoutMS
=>
{
export
const
initializeTestTimeout
=
(
defaultTimeoutMS
)
=>
{
setTestTimeout
(
defaultTimeoutMS
);
let
testStartTime
;
...
...
spec/frontend/helpers/tracking_helper.js
View file @
b6a8d9ba
...
...
@@ -14,7 +14,7 @@ export function mockTracking(category = '_category_', documentOverride, spyMetho
export
function
unmockTracking
()
{
window
.
snowplow
=
undefined
;
handlers
.
forEach
(
event
=>
document
.
removeEventListener
(
event
.
name
,
event
.
func
));
handlers
.
forEach
(
(
event
)
=>
document
.
removeEventListener
(
event
.
name
,
event
.
func
));
}
export
function
triggerEvent
(
selectorOrEl
,
eventName
=
'
click
'
)
{
...
...
spec/frontend/helpers/vue_mock_directive.js
View file @
b6a8d9ba
export
const
getKey
=
name
=>
`$_gl_jest_
${
name
}
`
;
export
const
getKey
=
(
name
)
=>
`$_gl_jest_
${
name
}
`
;
export
const
getBinding
=
(
el
,
name
)
=>
el
[
getKey
(
name
)];
...
...
spec/frontend/helpers/vue_test_utils_helper.js
View file @
b6a8d9ba
...
...
@@ -2,7 +2,7 @@ import { isArray } from 'lodash';
const
vNodeContainsText
=
(
vnode
,
text
)
=>
(
vnode
.
text
&&
vnode
.
text
.
includes
(
text
))
||
(
vnode
.
children
&&
vnode
.
children
.
filter
(
child
=>
vNodeContainsText
(
child
,
text
)).
length
);
(
vnode
.
children
&&
vnode
.
children
.
filter
(
(
child
)
=>
vNodeContainsText
(
child
,
text
)).
length
);
/**
* Determines whether a `shallowMount` Wrapper contains text
...
...
@@ -17,7 +17,7 @@ const vNodeContainsText = (vnode, text) =>
*/
export
const
shallowWrapperContainsSlotText
=
(
shallowWrapper
,
slotName
,
text
)
=>
Boolean
(
shallowWrapper
.
vm
.
$slots
[
slotName
].
filter
(
vnode
=>
vNodeContainsText
(
vnode
,
text
)).
length
,
shallowWrapper
.
vm
.
$slots
[
slotName
].
filter
(
(
vnode
)
=>
vNodeContainsText
(
vnode
,
text
)).
length
,
);
/**
...
...
@@ -27,8 +27,8 @@ export const shallowWrapperContainsSlotText = (shallowWrapper, slotName, text) =
* @param {String} expectedMutationType - The Mutation to wait for
*/
export
const
waitForMutation
=
(
store
,
expectedMutationType
)
=>
new
Promise
(
resolve
=>
{
const
unsubscribe
=
store
.
subscribe
(
mutation
=>
{
new
Promise
(
(
resolve
)
=>
{
const
unsubscribe
=
store
.
subscribe
(
(
mutation
)
=>
{
if
(
mutation
.
type
===
expectedMutationType
)
{
unsubscribe
();
resolve
();
...
...
@@ -36,7 +36,7 @@ export const waitForMutation = (store, expectedMutationType) =>
});
});
export
const
extendedWrapper
=
wrapper
=>
{
export
const
extendedWrapper
=
(
wrapper
)
=>
{
if
(
isArray
(
wrapper
)
||
!
wrapper
?.
find
)
{
// eslint-disable-next-line no-console
console
.
warn
(
...
...
spec/frontend/helpers/vuex_action_helper.js
View file @
b6a8d9ba
...
...
@@ -116,12 +116,12 @@ export default (
payload
,
);
return
(
result
||
new
Promise
(
resolve
=>
setImmediate
(
resolve
)))
.
catch
(
error
=>
{
return
(
result
||
new
Promise
(
(
resolve
)
=>
setImmediate
(
resolve
)))
.
catch
(
(
error
)
=>
{
validateResults
();
throw
error
;
})
.
then
(
data
=>
{
.
then
(
(
data
)
=>
{
validateResults
();
return
data
;
});
...
...
spec/frontend/helpers/vuex_action_helper_spec.js
View file @
b6a8d9ba
...
...
@@ -10,7 +10,7 @@ const testActionFnWithOptionsArg = (...args) => {
describe
.
each
([
testActionFn
,
testActionFnWithOptionsArg
])(
'
VueX test helper (testAction)
'
,
testAction
=>
{
(
testAction
)
=>
{
let
originalExpect
;
let
assertion
;
let
mock
;
...
...
@@ -25,7 +25,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
*/
originalExpect
=
expect
;
assertion
=
null
;
global
.
expect
=
actual
=>
({
global
.
expect
=
(
actual
)
=>
({
toEqual
:
()
=>
{
originalExpect
(
actual
).
toEqual
(
assertion
);
},
...
...
@@ -72,13 +72,13 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
testAction
(
action
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
,
noop
);
});
it
(
'
works with done callback once finished
'
,
done
=>
{
it
(
'
works with done callback once finished
'
,
(
done
)
=>
{
assertion
=
{
mutations
:
[],
actions
:
[]
};
testAction
(
noop
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
,
done
);
});
it
(
'
returns a promise
'
,
done
=>
{
it
(
'
returns a promise
'
,
(
done
)
=>
{
assertion
=
{
mutations
:
[],
actions
:
[]
};
testAction
(
noop
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
)
...
...
@@ -96,7 +96,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
return
axios
.
get
(
TEST_HOST
)
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
commit
(
'
ERROR
'
);
lastError
=
error
;
throw
error
;
...
...
@@ -111,7 +111,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
lastError
=
null
;
});
it
(
'
works with done callback once finished
'
,
done
=>
{
it
(
'
works with done callback once finished
'
,
(
done
)
=>
{
mock
.
onGet
(
TEST_HOST
).
replyOnce
(
200
,
42
);
assertion
=
{
mutations
:
[{
type
:
'
SUCCESS
'
}],
actions
:
[{
type
:
'
ACTION
'
}]
};
...
...
@@ -119,34 +119,34 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
testAction
(
asyncAction
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
,
done
);
});
it
(
'
returns original data of successful promise while checking actions/mutations
'
,
done
=>
{
it
(
'
returns original data of successful promise while checking actions/mutations
'
,
(
done
)
=>
{
mock
.
onGet
(
TEST_HOST
).
replyOnce
(
200
,
42
);
assertion
=
{
mutations
:
[{
type
:
'
SUCCESS
'
}],
actions
:
[{
type
:
'
ACTION
'
}]
};
testAction
(
asyncAction
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
)
.
then
(
res
=>
{
.
then
(
(
res
)
=>
{
originalExpect
(
res
).
toEqual
(
data
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns original error of rejected promise while checking actions/mutations
'
,
done
=>
{
it
(
'
returns original error of rejected promise while checking actions/mutations
'
,
(
done
)
=>
{
mock
.
onGet
(
TEST_HOST
).
replyOnce
(
500
,
''
);
assertion
=
{
mutations
:
[{
type
:
'
ERROR
'
}],
actions
:
[{
type
:
'
ACTION
'
}]
};
testAction
(
asyncAction
,
null
,
{},
assertion
.
mutations
,
assertion
.
actions
)
.
then
(
done
.
fail
)
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
originalExpect
(
error
).
toBe
(
lastError
);
done
();
});
});
});
it
(
'
works with async actions not returning promises
'
,
done
=>
{
it
(
'
works with async actions not returning promises
'
,
(
done
)
=>
{
const
data
=
{
FOO
:
'
BAR
'
};
const
asyncAction
=
({
commit
,
dispatch
})
=>
{
...
...
@@ -158,7 +158,7 @@ describe.each([testActionFn, testActionFnWithOptionsArg])(
commit
(
'
SUCCESS
'
);
return
data
;
})
.
catch
(
error
=>
{
.
catch
(
(
error
)
=>
{
commit
(
'
ERROR
'
);
throw
error
;
});
...
...
spec/frontend/helpers/wait_for_promises.js
View file @
b6a8d9ba
export
default
()
=>
new
Promise
(
resolve
=>
requestAnimationFrame
(
resolve
));
export
default
()
=>
new
Promise
(
(
resolve
)
=>
requestAnimationFrame
(
resolve
));
spec/frontend/helpers/wait_using_real_timer.js
View file @
b6a8d9ba
/* useful for timing promises when jest fakeTimers are not reliable enough */
export
default
timeout
=>
new
Promise
(
resolve
=>
{
export
default
(
timeout
)
=>
new
Promise
(
(
resolve
)
=>
{
jest
.
useRealTimers
();
setTimeout
(
resolve
,
timeout
);
jest
.
useFakeTimers
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment