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
Léo-Paul Géneau
gitlab-ce
Commits
870005c4
Commit
870005c4
authored
May 26, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for handleNotifications in mr_widget_options_spec.js
parent
71d03e7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
4 deletions
+47
-4
app/assets/javascripts/lib/utils/notify.js
app/assets/javascripts/lib/utils/notify.js
+7
-1
app/assets/javascripts/vue_merge_request_widget/dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+1
-1
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+2
-2
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
+37
-0
No files found.
app/assets/javascripts/lib/utils/notify.js
View file @
870005c4
...
@@ -39,4 +39,10 @@ function notifyMe(message, body, icon, onclick) {
...
@@ -39,4 +39,10 @@ function notifyMe(message, body, icon, onclick) {
}
}
}
}
export
{
notifyMe
as
default
,
notifyPermissions
,
notificationGranted
};
const
notify
=
{
notificationGranted
,
notifyPermissions
,
notifyMe
,
};
export
default
notify
;
app/assets/javascripts/vue_merge_request_widget/dependencies.js
View file @
870005c4
...
@@ -41,4 +41,4 @@ export { default as getStateKey } from './stores/get_state_key';
...
@@ -41,4 +41,4 @@ export { default as getStateKey } from './stores/get_state_key';
export
{
default
as
mrWidgetOptions
}
from
'
./mr_widget_options
'
;
export
{
default
as
mrWidgetOptions
}
from
'
./mr_widget_options
'
;
export
{
default
as
stateMaps
}
from
'
./stores/state_maps
'
;
export
{
default
as
stateMaps
}
from
'
./stores/state_maps
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
./components/states/mr_widget_squash_before_merge
'
;
export
{
default
as
SquashBeforeMerge
}
from
'
./components/states/mr_widget_squash_before_merge
'
;
export
{
default
as
notify
Me
}
from
'
../lib/utils/notify
'
;
export
{
default
as
notify
}
from
'
../lib/utils/notify
'
;
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
870005c4
...
@@ -29,7 +29,7 @@ import {
...
@@ -29,7 +29,7 @@ import {
eventHub
,
eventHub
,
stateMaps
,
stateMaps
,
SquashBeforeMerge
,
SquashBeforeMerge
,
notify
Me
,
notify
,
}
from
'
./dependencies
'
;
}
from
'
./dependencies
'
;
export
default
{
export
default
{
...
@@ -146,7 +146,7 @@ export default {
...
@@ -146,7 +146,7 @@ export default {
const
title
=
`Pipeline
${
label
}
`
;
const
title
=
`Pipeline
${
label
}
`
;
const
message
=
`Pipeline
${
label
}
for "
${
data
.
title
}
"`
;
const
message
=
`Pipeline
${
label
}
for "
${
data
.
title
}
"`
;
notifyMe
(
title
,
message
,
this
.
mr
.
gitlabLogo
);
notify
.
notify
Me
(
title
,
message
,
this
.
mr
.
gitlabLogo
);
},
},
resumePolling
()
{
resumePolling
()
{
this
.
pollingInterval
.
resume
();
this
.
pollingInterval
.
resume
();
...
...
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
View file @
870005c4
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
import
MRWidgetService
from
'
~/vue_merge_request_widget/services/mr_widget_service
'
;
import
MRWidgetService
from
'
~/vue_merge_request_widget/services/mr_widget_service
'
;
import
mrWidgetOptions
from
'
~/vue_merge_request_widget/mr_widget_options
'
;
import
mrWidgetOptions
from
'
~/vue_merge_request_widget/mr_widget_options
'
;
import
eventHub
from
'
~/vue_merge_request_widget/event_hub
'
;
import
eventHub
from
'
~/vue_merge_request_widget/event_hub
'
;
import
notify
from
'
~/lib/utils/notify
'
;
import
mockData
from
'
./mock_data
'
;
import
mockData
from
'
./mock_data
'
;
const
createComponent
=
()
=>
{
const
createComponent
=
()
=>
{
...
@@ -107,6 +108,8 @@ describe('mrWidgetOptions', () => {
...
@@ -107,6 +108,8 @@ describe('mrWidgetOptions', () => {
it
(
'
should tell service to check status
'
,
(
done
)
=>
{
it
(
'
should tell service to check status
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
checkStatus
'
).
and
.
returnValue
(
returnPromise
(
mockData
));
spyOn
(
vm
.
service
,
'
checkStatus
'
).
and
.
returnValue
(
returnPromise
(
mockData
));
spyOn
(
vm
.
mr
,
'
setData
'
);
spyOn
(
vm
.
mr
,
'
setData
'
);
spyOn
(
vm
,
'
handleNotification
'
);
let
isCbExecuted
=
false
;
let
isCbExecuted
=
false
;
const
cb
=
()
=>
{
const
cb
=
()
=>
{
isCbExecuted
=
true
;
isCbExecuted
=
true
;
...
@@ -117,6 +120,7 @@ describe('mrWidgetOptions', () => {
...
@@ -117,6 +120,7 @@ describe('mrWidgetOptions', () => {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
service
.
checkStatus
).
toHaveBeenCalled
();
expect
(
vm
.
service
.
checkStatus
).
toHaveBeenCalled
();
expect
(
vm
.
mr
.
setData
).
toHaveBeenCalled
();
expect
(
vm
.
mr
.
setData
).
toHaveBeenCalled
();
expect
(
vm
.
handleNotification
).
toHaveBeenCalledWith
(
mockData
);
expect
(
isCbExecuted
).
toBeTruthy
();
expect
(
isCbExecuted
).
toBeTruthy
();
done
();
done
();
},
333
);
},
333
);
...
@@ -254,6 +258,39 @@ describe('mrWidgetOptions', () => {
...
@@ -254,6 +258,39 @@ describe('mrWidgetOptions', () => {
});
});
});
});
describe
(
'
handleNotification
'
,
()
=>
{
const
data
=
{
ci_status
:
'
running
'
,
title
:
'
title
'
,
pipeline
:
{
details
:
{
status
:
{
label
:
'
running-label
'
}
}
},
};
beforeEach
(()
=>
{
spyOn
(
notify
,
'
notifyMe
'
);
vm
.
mr
.
ciStatus
=
'
failed
'
;
vm
.
mr
.
gitlabLogo
=
'
logo.png
'
;
});
it
(
'
should call notifyMe
'
,
()
=>
{
vm
.
handleNotification
(
data
);
expect
(
notify
.
notifyMe
).
toHaveBeenCalledWith
(
'
Pipeline running-label
'
,
'
Pipeline running-label for "title"
'
,
'
logo.png
'
,
);
});
it
(
'
should not call notifyMe if the status has not changed
'
,
()
=>
{
vm
.
mr
.
ciStatus
=
data
.
ci_status
;
vm
.
handleNotification
(
data
);
expect
(
notify
.
notifyMe
).
not
.
toHaveBeenCalled
();
});
});
describe
(
'
resumePolling
'
,
()
=>
{
describe
(
'
resumePolling
'
,
()
=>
{
it
(
'
should call stopTimer on pollingInterval
'
,
()
=>
{
it
(
'
should call stopTimer on pollingInterval
'
,
()
=>
{
spyOn
(
vm
.
pollingInterval
,
'
resume
'
);
spyOn
(
vm
.
pollingInterval
,
'
resume
'
);
...
...
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