1
1
import { render } from '@1024pix/ember-testing-library' ;
2
+ import { click } from '@ember/test-helpers' ;
2
3
import { hbs } from 'ember-cli-htmlbars' ;
3
4
import { t } from 'ember-intl/test-support' ;
4
5
import { module , test } from 'qunit' ;
6
+ import sinon from 'sinon' ;
5
7
6
8
import setupIntlRenderingTest from '../../../../../helpers/setup-intl-rendering' ;
7
9
@@ -10,6 +12,7 @@ module('Integration | Components | Campaigns | Assessment | Results | Evaluation
10
12
11
13
module ( 'when there are rewards and trainings' , function ( hooks ) {
12
14
let screen ;
15
+ let onResultsSharedStub ;
13
16
14
17
hooks . beforeEach ( async function ( ) {
15
18
// given
@@ -18,16 +21,22 @@ module('Integration | Components | Campaigns | Assessment | Results | Evaluation
18
21
const acquiredBadge = store . createRecord ( 'badge' , { isAcquired : true } ) ;
19
22
this . set ( 'campaignParticipationResult' , {
20
23
campaignParticipationBadges : [ acquiredBadge ] ,
24
+ isShared : false ,
21
25
} ) ;
22
26
23
27
const training = store . createRecord ( 'training' , { duration : { days : 2 } } ) ;
24
28
this . set ( 'trainings' , [ training ] ) ;
25
29
30
+ onResultsSharedStub = sinon . stub ( ) ;
31
+ this . set ( 'onResultsShared' , onResultsSharedStub ) ;
32
+
26
33
// when
27
34
screen = await render (
28
35
hbs `<Campaigns::Assessment::Results::EvaluationResultsTabs
29
36
@campaignParticipationResult={{this.campaignParticipationResult}}
30
37
@trainings={{this.trainings}}
38
+ @onResultsShared={{this.onResultsShared}}
39
+ @isSharableCampaign={{true}}
31
40
/>` ,
32
41
) ;
33
42
} ) ;
@@ -45,6 +54,21 @@ module('Integration | Components | Campaigns | Assessment | Results | Evaluation
45
54
// then
46
55
assert . dom ( screen . getByRole ( 'heading' , { name : t ( 'pages.skill-review.tabs.rewards.title' ) } ) ) . isVisible ( ) ;
47
56
} ) ;
57
+
58
+ module ( 'when clicking on shared results button' , function ( ) {
59
+ test ( 'it should call onResultsShared' , async function ( assert ) {
60
+ // given
61
+ const campaignParticipationResultService = this . owner . lookup ( 'service:campaign-participation-result' ) ;
62
+ sinon . stub ( campaignParticipationResultService , 'share' ) ;
63
+
64
+ // when
65
+ await click ( screen . queryByRole ( 'tab' , { name : 'Formations' } ) ) ;
66
+ await click ( screen . queryByRole ( 'button' , { name : t ( 'pages.skill-review.actions.send' ) } ) ) ;
67
+
68
+ // then
69
+ assert . true ( onResultsSharedStub . calledOnce ) ;
70
+ } ) ;
71
+ } ) ;
48
72
} ) ;
49
73
50
74
module ( 'when there are rewards but no trainings' , function ( ) {
0 commit comments