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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
2c47f092
Commit
2c47f092
authored
Jan 03, 2018
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add id to modal.vue to support data-toggle="modal"
parent
b1e1990e
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
168 additions
and
115 deletions
+168
-115
app/assets/javascripts/groups/components/item_actions.vue
app/assets/javascripts/groups/components/item_actions.vue
+2
-4
app/assets/javascripts/ide/components/new_dropdown/index.vue
app/assets/javascripts/ide/components/new_dropdown/index.vue
+4
-4
app/assets/javascripts/ide/components/new_dropdown/modal.vue
app/assets/javascripts/ide/components/new_dropdown/modal.vue
+4
-4
app/assets/javascripts/ide/components/repo_commit_section.vue
...assets/javascripts/ide/components/repo_commit_section.vue
+1
-1
app/assets/javascripts/ide/components/repo_edit_button.vue
app/assets/javascripts/ide/components/repo_edit_button.vue
+1
-1
app/assets/javascripts/profile/account/components/delete_account_modal.vue
...ripts/profile/account/components/delete_account_modal.vue
+45
-66
app/assets/javascripts/profile/account/index.js
app/assets/javascripts/profile/account/index.js
+8
-0
app/assets/javascripts/vue_shared/components/modal.vue
app/assets/javascripts/vue_shared/components/modal.vue
+21
-9
app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
...ets/javascripts/vue_shared/components/recaptcha_modal.vue
+1
-1
app/views/profiles/accounts/show.html.haml
app/views/profiles/accounts/show.html.haml
+4
-2
changelogs/unreleased/winh-modal-target-id.yml
changelogs/unreleased/winh-modal-target-id.yml
+5
-0
spec/javascripts/groups/components/item_actions_spec.js
spec/javascripts/groups/components/item_actions_spec.js
+3
-9
spec/javascripts/profile/account/components/delete_account_modal_spec.js
...s/profile/account/components/delete_account_modal_spec.js
+4
-4
spec/javascripts/repo/components/new_dropdown/index_spec.js
spec/javascripts/repo/components/new_dropdown/index_spec.js
+7
-6
spec/javascripts/vue_shared/components/modal_spec.js
spec/javascripts/vue_shared/components/modal_spec.js
+58
-4
No files found.
app/assets/javascripts/groups/components/item_actions.vue
View file @
2c47f092
...
@@ -45,11 +45,9 @@ export default {
...
@@ -45,11 +45,9 @@ export default {
onLeaveGroup
()
{
onLeaveGroup
()
{
this
.
modalStatus
=
true
;
this
.
modalStatus
=
true
;
},
},
leaveGroup
(
leaveConfirmed
)
{
leaveGroup
()
{
this
.
modalStatus
=
false
;
this
.
modalStatus
=
false
;
if
(
leaveConfirmed
)
{
eventHub
.
$emit
(
'
leaveGroup
'
,
this
.
group
,
this
.
parentGroup
);
eventHub
.
$emit
(
'
leaveGroup
'
,
this
.
group
,
this
.
parentGroup
);
}
},
},
},
},
};
};
...
...
app/assets/javascripts/ide/components/new_dropdown/index.vue
View file @
2c47f092
...
@@ -32,10 +32,10 @@
...
@@ -32,10 +32,10 @@
methods
:
{
methods
:
{
createNewItem
(
type
)
{
createNewItem
(
type
)
{
this
.
modalType
=
type
;
this
.
modalType
=
type
;
this
.
toggleModalOpen
()
;
this
.
openModal
=
true
;
},
},
toggleModalOpen
()
{
hideModal
()
{
this
.
openModal
=
!
this
.
openModal
;
this
.
openModal
=
false
;
},
},
},
},
};
};
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
:branch-id=
"branch"
:branch-id=
"branch"
:path=
"path"
:path=
"path"
:parent=
"parent"
:parent=
"parent"
@
toggle=
"toggleModalOpen
"
@
hide=
"hideModal
"
/>
/>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/ide/components/new_dropdown/modal.vue
View file @
2c47f092
...
@@ -43,10 +43,10 @@
...
@@ -43,10 +43,10 @@
type
:
this
.
type
,
type
:
this
.
type
,
});
});
this
.
toggleModalOpen
();
this
.
hideModal
();
},
},
toggleModalOpen
()
{
hideModal
()
{
this
.
$emit
(
'
toggl
e
'
);
this
.
$emit
(
'
hid
e
'
);
},
},
},
},
computed
:
{
computed
:
{
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
:title=
"modalTitle"
:title=
"modalTitle"
:primary-button-label=
"buttonLabel"
:primary-button-label=
"buttonLabel"
kind=
"success"
kind=
"success"
@
toggle=
"toggleModalOpen
"
@
cancel=
"hideModal
"
@
submit=
"createEntryInStore"
@
submit=
"createEntryInStore"
>
>
<form
<form
...
...
app/assets/javascripts/ide/components/repo_commit_section.vue
View file @
2c47f092
...
@@ -110,7 +110,7 @@ export default {
...
@@ -110,7 +110,7 @@ export default {
kind=
"primary"
kind=
"primary"
:title=
"__('Branch has changed')"
:title=
"__('Branch has changed')"
:text=
"__('This branch has changed since you started editing. Would you like to create a new branch?')"
:text=
"__('This branch has changed since you started editing. Would you like to create a new branch?')"
@
toggle
=
"showNewBranchModal = false"
@
cancel
=
"showNewBranchModal = false"
@
submit=
"makeCommit(true)"
@
submit=
"makeCommit(true)"
/>
/>
<commit-files-list
<commit-files-list
...
...
app/assets/javascripts/ide/components/repo_edit_button.vue
View file @
2c47f092
...
@@ -50,7 +50,7 @@ export default {
...
@@ -50,7 +50,7 @@ export default {
kind=
"warning"
kind=
"warning"
:title=
"__('Are you sure?')"
:title=
"__('Are you sure?')"
:text=
"__('Are you sure you want to discard your changes?')"
:text=
"__('Are you sure you want to discard your changes?')"
@
toggle
=
"closeDiscardPopup"
@
cancel
=
"closeDiscardPopup"
@
submit=
"toggleEditMode(true)"
@
submit=
"toggleEditMode(true)"
/>
/>
</div>
</div>
...
...
app/assets/javascripts/profile/account/components/delete_account_modal.vue
View file @
2c47f092
<
script
>
<
script
>
import
modal
from
'
../../..
/vue_shared/components/modal.vue
'
;
import
modal
from
'
~
/vue_shared/components/modal.vue
'
;
import
{
__
,
s__
,
sprintf
}
from
'
../../..
/locale
'
;
import
{
__
,
s__
,
sprintf
}
from
'
~
/locale
'
;
import
csrf
from
'
../../..
/lib/utils/csrf
'
;
import
csrf
from
'
~
/lib/utils/csrf
'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
return
{
return
{
enteredPassword
:
''
,
enteredPassword
:
''
,
enteredUsername
:
''
,
enteredUsername
:
''
,
isOpen
:
false
,
};
};
},
},
components
:
{
components
:
{
...
@@ -69,78 +68,58 @@ Once you confirm %{deleteAccount}, it cannot be undone or recovered.`),
...
@@ -69,78 +68,58 @@ Once you confirm %{deleteAccount}, it cannot be undone or recovered.`),
return
this
.
enteredUsername
===
this
.
username
;
return
this
.
enteredUsername
===
this
.
username
;
},
},
onSubmit
(
status
)
{
onSubmit
()
{
if
(
status
)
{
this
.
$refs
.
form
.
submit
();
if
(
!
this
.
canSubmit
())
{
return
;
}
this
.
$refs
.
form
.
submit
();
}
this
.
toggleOpen
(
false
);
},
toggleOpen
(
isOpen
)
{
this
.
isOpen
=
isOpen
;
},
},
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<modal
<modal
id=
"delete-account-modal"
v-if=
"isOpen"
:title=
"s__('Profiles|Delete your account?')"
:title=
"s__('Profiles|Delete your account?')"
:text=
"text"
:text=
"text"
kind=
"danger"
:kind=
"`danger $
{!canSubmit()
&&
'disabled'}`"
:primary-button-label=
"s__('Profiles|Delete account')"
:primary-button-label="s__('Profiles|Delete account')"
@
submit=
"onSubmit"
@toggle="toggleOpen"
:submit-disabled=
"!canSubmit()"
>
@submit="onSubmit">
<template
slot=
"body"
slot-scope=
"props"
>
<p
v-html=
"props.text"
></p>
<form
<template
slot=
"body"
slot-scope=
"props"
>
ref=
"form"
<p
v-html=
"props.text"
></p>
:action=
"actionUrl"
method=
"post"
>
<input
<form
type=
"hidden"
ref=
"form"
name=
"_method"
:action=
"actionUrl"
value=
"delete"
/>
method=
"post"
>
<input
type=
"hidden"
name=
"authenticity_token"
:value=
"csrfToken"
/>
<p
id=
"input-label"
v-html=
"inputLabel"
></p>
<input
type=
"hidden"
name=
"_method"
value=
"delete"
/>
<input
type=
"hidden"
name=
"authenticity_token"
:value=
"csrfToken"
/>
<input
<p
id=
"input-label"
v-html=
"inputLabel"
></p>
v-if=
"confirmWithPassword"
name=
"password"
class=
"form-control"
type=
"password"
v-model=
"enteredPassword"
aria-labelledby=
"input-label"
/>
<input
v-else
name=
"username"
class=
"form-control"
type=
"text"
v-model=
"enteredUsername"
aria-labelledby=
"input-label"
/>
</form>
</
template
>
</modal>
<input
v-if=
"confirmWithPassword"
name=
"password"
class=
"form-control"
type=
"password"
v-model=
"enteredPassword"
aria-labelledby=
"input-label"
/>
<input
v-else
name=
"username"
class=
"form-control"
type=
"text"
v-model=
"enteredUsername"
aria-labelledby=
"input-label"
/>
</form>
</
template
>
<button
</modal>
type=
"button"
class=
"btn btn-danger"
@
click=
"toggleOpen(true)"
>
{{ s__('Profiles|Delete account') }}
</button>
</div>
</template>
</template>
app/assets/javascripts/profile/account/index.js
View file @
2c47f092
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Translate
from
'
~/vue_shared/translate
'
;
import
deleteAccountModal
from
'
./components/delete_account_modal.vue
'
;
import
deleteAccountModal
from
'
./components/delete_account_modal.vue
'
;
Vue
.
use
(
Translate
);
const
deleteAccountButton
=
document
.
getElementById
(
'
delete-account-button
'
);
const
deleteAccountModalEl
=
document
.
getElementById
(
'
delete-account-modal
'
);
const
deleteAccountModalEl
=
document
.
getElementById
(
'
delete-account-modal
'
);
// eslint-disable-next-line no-new
// eslint-disable-next-line no-new
new
Vue
({
new
Vue
({
...
@@ -9,6 +14,9 @@ new Vue({
...
@@ -9,6 +14,9 @@ new Vue({
components
:
{
components
:
{
deleteAccountModal
,
deleteAccountModal
,
},
},
mounted
()
{
deleteAccountButton
.
classList
.
remove
(
'
disabled
'
);
},
render
(
createElement
)
{
render
(
createElement
)
{
return
createElement
(
'
delete-account-modal
'
,
{
return
createElement
(
'
delete-account-modal
'
,
{
props
:
{
props
:
{
...
...
app/assets/javascripts/vue_shared/components/modal.vue
View file @
2c47f092
...
@@ -3,6 +3,10 @@ export default {
...
@@ -3,6 +3,10 @@ export default {
name
:
'
modal
'
,
name
:
'
modal
'
,
props
:
{
props
:
{
id
:
{
type
:
String
,
required
:
false
,
},
title
:
{
title
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
...
@@ -62,11 +66,11 @@ export default {
...
@@ -62,11 +66,11 @@ export default {
},
},
methods
:
{
methods
:
{
close
(
)
{
emitCancel
(
event
)
{
this
.
$emit
(
'
toggle
'
,
false
);
this
.
$emit
(
'
cancel
'
,
event
);
},
},
emitSubmit
(
status
)
{
emitSubmit
(
event
)
{
this
.
$emit
(
'
submit
'
,
status
);
this
.
$emit
(
'
submit
'
,
event
);
},
},
},
},
};
};
...
@@ -75,7 +79,9 @@ export default {
...
@@ -75,7 +79,9 @@ export default {
<
template
>
<
template
>
<div
class=
"modal-open"
>
<div
class=
"modal-open"
>
<div
<div
class=
"modal show"
:id=
"id"
class=
"modal"
:class=
"id ? '' : 'show'"
role=
"dialog"
role=
"dialog"
tabindex=
"-1"
tabindex=
"-1"
>
>
...
@@ -93,7 +99,8 @@ export default {
...
@@ -93,7 +99,8 @@ export default {
<button
<button
type=
"button"
type=
"button"
class=
"close pull-right"
class=
"close pull-right"
@
click=
"close"
@
click=
"emitCancel($event)"
data-dismiss=
"modal"
aria-label=
"Close"
aria-label=
"Close"
>
>
<span
aria-hidden=
"true"
>
×
</span>
<span
aria-hidden=
"true"
>
×
</span>
...
@@ -110,7 +117,8 @@ export default {
...
@@ -110,7 +117,8 @@ export default {
type=
"button"
type=
"button"
class=
"btn pull-left"
class=
"btn pull-left"
:class=
"btnCancelKindClass"
:class=
"btnCancelKindClass"
@
click=
"close"
>
@
click=
"emitCancel($event)"
data-dismiss=
"modal"
>
{{
closeButtonLabel
}}
{{
closeButtonLabel
}}
</button>
</button>
<button
<button
...
@@ -119,13 +127,17 @@ export default {
...
@@ -119,13 +127,17 @@ export default {
class=
"btn pull-right js-primary-button"
class=
"btn pull-right js-primary-button"
:disabled=
"submitDisabled"
:disabled=
"submitDisabled"
:class=
"btnKindClass"
:class=
"btnKindClass"
@
click=
"emitSubmit(true)"
>
@
click=
"emitSubmit($event)"
data-dismiss=
"modal"
>
{{
primaryButtonLabel
}}
{{
primaryButtonLabel
}}
</button>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"modal-backdrop fade in"
/>
<div
v-if=
"!id"
class=
"modal-backdrop fade in"
>
</div>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/vue_shared/components/recaptcha_modal.vue
View file @
2c47f092
...
@@ -70,7 +70,7 @@ export default {
...
@@ -70,7 +70,7 @@ export default {
class=
"recaptcha-modal js-recaptcha-modal"
class=
"recaptcha-modal js-recaptcha-modal"
:hide-footer=
"true"
:hide-footer=
"true"
:title=
"__('Please solve the reCAPTCHA')"
:title=
"__('Please solve the reCAPTCHA')"
@
toggle
=
"close"
@
cancel
=
"close"
>
>
<div
slot=
"body"
>
<div
slot=
"body"
>
<p>
<p>
...
...
app/views/profiles/accounts/show.html.haml
View file @
2c47f092
...
@@ -84,11 +84,13 @@
...
@@ -84,11 +84,13 @@
=
s_
(
'Profiles|Deleting an account has the following effects:'
)
=
s_
(
'Profiles|Deleting an account has the following effects:'
)
=
render
'users/deletion_guidance'
,
user:
current_user
=
render
'users/deletion_guidance'
,
user:
current_user
%button
#delete-account-button
.btn.btn-danger.disabled
{
data:
{
toggle:
'modal'
,
target:
'#delete-account-modal'
}
}
=
s_
(
'Profiles|Delete account'
)
#delete-account-modal
{
data:
{
action_url:
user_registration_path
,
#delete-account-modal
{
data:
{
action_url:
user_registration_path
,
confirm_with_password:
(
'true'
if
current_user
.
confirm_deletion_with_password?
),
confirm_with_password:
(
'true'
if
current_user
.
confirm_deletion_with_password?
),
username:
current_user
.
username
}
}
username:
current_user
.
username
}
}
%button
.btn.btn-danger.disabled
=
s_
(
'Profiles|Delete account'
)
-
else
-
else
-
if
@user
.
solo_owned_groups
.
present?
-
if
@user
.
solo_owned_groups
.
present?
%p
%p
...
...
changelogs/unreleased/winh-modal-target-id.yml
0 → 100644
View file @
2c47f092
---
title
:
Add id to modal.vue to support data-toggle="modal"
merge_request
:
16189
author
:
type
:
other
spec/javascripts/groups/components/item_actions_spec.js
View file @
2c47f092
...
@@ -47,17 +47,11 @@ describe('ItemActionsComponent', () => {
...
@@ -47,17 +47,11 @@ describe('ItemActionsComponent', () => {
it
(
'
should change `modalStatus` prop to `false` and emit `leaveGroup` event with required params when called with `leaveConfirmed` as `true`
'
,
()
=>
{
it
(
'
should change `modalStatus` prop to `false` and emit `leaveGroup` event with required params when called with `leaveConfirmed` as `true`
'
,
()
=>
{
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
eventHub
,
'
$emit
'
);
vm
.
modalStatus
=
true
;
vm
.
modalStatus
=
true
;
vm
.
leaveGroup
(
true
);
expect
(
vm
.
modalStatus
).
toBeFalsy
();
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
leaveGroup
'
,
vm
.
group
,
vm
.
parentGroup
);
});
it
(
'
should change `modalStatus` prop to `false` and should NOT emit `leaveGroup` event when called with `leaveConfirmed` as `false`
'
,
()
=>
{
vm
.
leaveGroup
();
spyOn
(
eventHub
,
'
$emit
'
);
vm
.
modalStatus
=
true
;
vm
.
leaveGroup
(
false
);
expect
(
vm
.
modalStatus
).
toBeFalsy
();
expect
(
vm
.
modalStatus
).
toBeFalsy
();
expect
(
eventHub
.
$emit
).
not
.
toHaveBeenCalled
(
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
leaveGroup
'
,
vm
.
group
,
vm
.
parentGroup
);
});
});
});
});
});
});
...
...
spec/javascripts/profile/account/components/delete_account_modal_spec.js
View file @
2c47f092
...
@@ -51,7 +51,7 @@ describe('DeleteAccountModal component', () => {
...
@@ -51,7 +51,7 @@ describe('DeleteAccountModal component', () => {
Vue
.
nextTick
()
Vue
.
nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
enteredPassword
).
toBe
(
input
.
value
);
expect
(
vm
.
enteredPassword
).
toBe
(
input
.
value
);
expect
(
submitButton
).
toHave
Class
(
'
disabled
'
);
expect
(
submitButton
).
toHave
Attr
(
'
disabled
'
,
'
disabled
'
);
submitButton
.
click
();
submitButton
.
click
();
expect
(
form
.
submit
).
not
.
toHaveBeenCalled
();
expect
(
form
.
submit
).
not
.
toHaveBeenCalled
();
})
})
...
@@ -68,7 +68,7 @@ describe('DeleteAccountModal component', () => {
...
@@ -68,7 +68,7 @@ describe('DeleteAccountModal component', () => {
Vue
.
nextTick
()
Vue
.
nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
enteredPassword
).
toBe
(
input
.
value
);
expect
(
vm
.
enteredPassword
).
toBe
(
input
.
value
);
expect
(
submitButton
).
not
.
toHave
Class
(
'
disabled
'
);
expect
(
submitButton
).
not
.
toHave
Attr
(
'
disabled
'
,
'
disabled
'
);
submitButton
.
click
();
submitButton
.
click
();
expect
(
form
.
submit
).
toHaveBeenCalled
();
expect
(
form
.
submit
).
toHaveBeenCalled
();
})
})
...
@@ -101,7 +101,7 @@ describe('DeleteAccountModal component', () => {
...
@@ -101,7 +101,7 @@ describe('DeleteAccountModal component', () => {
Vue
.
nextTick
()
Vue
.
nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
enteredUsername
).
toBe
(
input
.
value
);
expect
(
vm
.
enteredUsername
).
toBe
(
input
.
value
);
expect
(
submitButton
).
toHave
Class
(
'
disabled
'
);
expect
(
submitButton
).
toHave
Attr
(
'
disabled
'
,
'
disabled
'
);
submitButton
.
click
();
submitButton
.
click
();
expect
(
form
.
submit
).
not
.
toHaveBeenCalled
();
expect
(
form
.
submit
).
not
.
toHaveBeenCalled
();
})
})
...
@@ -118,7 +118,7 @@ describe('DeleteAccountModal component', () => {
...
@@ -118,7 +118,7 @@ describe('DeleteAccountModal component', () => {
Vue
.
nextTick
()
Vue
.
nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
enteredUsername
).
toBe
(
input
.
value
);
expect
(
vm
.
enteredUsername
).
toBe
(
input
.
value
);
expect
(
submitButton
).
not
.
toHave
Class
(
'
disabled
'
);
expect
(
submitButton
).
not
.
toHave
Attr
(
'
disabled
'
,
'
disabled
'
);
submitButton
.
click
();
submitButton
.
click
();
expect
(
form
.
submit
).
toHaveBeenCalled
();
expect
(
form
.
submit
).
toHaveBeenCalled
();
})
})
...
...
spec/javascripts/repo/components/new_dropdown/index_spec.js
View file @
2c47f092
...
@@ -57,15 +57,16 @@ describe('new dropdown component', () => {
...
@@ -57,15 +57,16 @@ describe('new dropdown component', () => {
});
});
});
});
describe
(
'
toggleModalOpen
'
,
()
=>
{
describe
(
'
hideModal
'
,
()
=>
{
beforeAll
((
done
)
=>
{
vm
.
openModal
=
true
;
Vue
.
nextTick
(
done
);
});
it
(
'
closes modal after toggling
'
,
(
done
)
=>
{
it
(
'
closes modal after toggling
'
,
(
done
)
=>
{
vm
.
toggleModalOpen
();
vm
.
hideModal
();
Vue
.
nextTick
()
Vue
.
nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.modal
'
)).
not
.
toBeNull
();
})
.
then
(
vm
.
toggleModalOpen
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.modal
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.modal
'
)).
toBeNull
();
})
})
...
...
spec/javascripts/vue_shared/components/modal_spec.js
View file @
2c47f092
...
@@ -2,11 +2,65 @@ import Vue from 'vue';
...
@@ -2,11 +2,65 @@ import Vue from 'vue';
import
modal
from
'
~/vue_shared/components/modal.vue
'
;
import
modal
from
'
~/vue_shared/components/modal.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
const
modalComponent
=
Vue
.
extend
(
modal
);
describe
(
'
Modal
'
,
()
=>
{
describe
(
'
Modal
'
,
()
=>
{
it
(
'
does not render a primary button if no primaryButtonLabel
'
,
()
=>
{
let
vm
;
const
modalComponent
=
Vue
.
extend
(
modal
);
const
vm
=
mountComponent
(
modalComponent
);
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
props
'
,
()
=>
{
describe
(
'
without primaryButtonLabel
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
primaryButtonLabel
:
null
,
});
});
it
(
'
does not render a primary button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-primary-button
'
)).
toBeNull
();
});
});
describe
(
'
with id
'
,
()
=>
{
it
(
'
does not render a primary button
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
id
:
'
my-modal
'
,
});
});
it
(
'
assigns the id to the modal
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
#my-modal.modal
'
)).
not
.
toBeNull
();
});
it
(
'
does not show the modal immediately
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
#my-modal.modal
'
)).
not
.
toHaveClass
(
'
show
'
);
});
it
(
'
does not show a backdrop
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
modal-backdrop
'
)).
toBeNull
();
});
});
});
it
(
'
works with data-toggle="modal"
'
,
(
done
)
=>
{
setFixtures
(
`
<button id="modal-button" data-toggle="modal" data-target="#my-modal"></button>
<div id="modal-container"></div>
`
);
const
modalContainer
=
document
.
getElementById
(
'
modal-container
'
);
const
modalButton
=
document
.
getElementById
(
'
modal-button
'
);
vm
=
mountComponent
(
modalComponent
,
{
id
:
'
my-modal
'
,
},
modalContainer
);
const
modalElement
=
vm
.
$el
.
querySelector
(
'
#my-modal
'
);
$
(
modalElement
).
on
(
'
shown.bs.modal
'
,
()
=>
done
());
expect
(
vm
.
$el
.
querySelector
(
'
.js-primary-button
'
)).
toBeNull
();
modalButton
.
click
();
});
});
});
});
});
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