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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-25 03:06:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-25 03:06:14 +0300
commit6d43720a1a86ccca9618417a6d0415e7d522fa49 (patch)
treeceab63f6374252b8afe4913b949bae39a027366f /spec/frontend/performance_bar/components
parent46bfa73d93786bc2a832be7e42e2119712a0bafb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/performance_bar/components')
-rw-r--r--spec/frontend/performance_bar/components/add_request_spec.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/frontend/performance_bar/components/add_request_spec.js b/spec/frontend/performance_bar/components/add_request_spec.js
new file mode 100644
index 00000000000..cef264f3915
--- /dev/null
+++ b/spec/frontend/performance_bar/components/add_request_spec.js
@@ -0,0 +1,62 @@
+import AddRequest from '~/performance_bar/components/add_request.vue';
+import { shallowMount } from '@vue/test-utils';
+
+describe('add request form', () => {
+ let wrapper;
+
+ beforeEach(() => {
+ wrapper = shallowMount(AddRequest);
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('hides the input on load', () => {
+ expect(wrapper.find('input').exists()).toBe(false);
+ });
+
+ describe('when clicking the button', () => {
+ beforeEach(() => {
+ wrapper.find('button').trigger('click');
+ });
+
+ it('shows the form', () => {
+ expect(wrapper.find('input').exists()).toBe(true);
+ });
+
+ describe('when pressing escape', () => {
+ beforeEach(() => {
+ wrapper.find('input').trigger('keyup.esc');
+ });
+
+ it('hides the input', () => {
+ expect(wrapper.find('input').exists()).toBe(false);
+ });
+ });
+
+ describe('when submitting the form', () => {
+ beforeEach(() => {
+ wrapper.find('input').setValue('http://gitlab.example.com/users/root/calendar.json');
+ wrapper.find('input').trigger('keyup.enter');
+ });
+
+ it('emits an event to add the request', () => {
+ expect(wrapper.emitted()['add-request']).toBeTruthy();
+ expect(wrapper.emitted()['add-request'][0]).toEqual([
+ 'http://gitlab.example.com/users/root/calendar.json',
+ ]);
+ });
+
+ it('hides the input', () => {
+ expect(wrapper.find('input').exists()).toBe(false);
+ });
+
+ it('clears the value for next time', () => {
+ wrapper.find('button').trigger('click');
+
+ expect(wrapper.find('input').text()).toEqual('');
+ });
+ });
+ });
+});