@@ -74,24 +74,6 @@ const mockActivatedRoute = {
74
74
} ,
75
75
} ;
76
76
77
- const alignmentPossibilities = [
78
- {
79
- objectiveId : 1003 ,
80
- objectiveTitle : 'O - Test Objective' ,
81
- keyResultAlignmentsDtos : [ ] ,
82
- } ,
83
- {
84
- objectiveId : 1005 ,
85
- objectiveTitle : 'O - Company will grow' ,
86
- keyResultAlignmentsDtos : [
87
- {
88
- keyResultId : 6 ,
89
- keyResultTitle : 'K - New structure' ,
90
- } ,
91
- ] ,
92
- } ,
93
- ] ;
94
-
95
77
describe ( 'ObjectiveDialogComponent' , ( ) => {
96
78
let component : ObjectiveFormComponent ;
97
79
let fixture : ComponentFixture < ObjectiveFormComponent > ;
@@ -430,12 +412,66 @@ describe('ObjectiveDialogComponent', () => {
430
412
fixture . detectChanges ( ) ;
431
413
expect ( component . allowedOption ( quarter ) ) . toBeTruthy ( ) ;
432
414
} ) ;
415
+ } ) ;
416
+
417
+ describe ( 'AlignmentPossibilities' , ( ) => {
418
+ beforeEach ( ( ) => {
419
+ TestBed . configureTestingModule ( {
420
+ imports : [
421
+ HttpClientTestingModule ,
422
+ MatDialogModule ,
423
+ MatIconModule ,
424
+ MatFormFieldModule ,
425
+ MatSelectModule ,
426
+ ReactiveFormsModule ,
427
+ MatInputModule ,
428
+ NoopAnimationsModule ,
429
+ MatCheckboxModule ,
430
+ RouterTestingModule ,
431
+ TranslateTestingModule . withTranslations ( {
432
+ de : de ,
433
+ } ) ,
434
+ ] ,
435
+ declarations : [ ObjectiveFormComponent , DialogHeaderComponent ] ,
436
+ providers : [
437
+ { provide : MatDialogRef , useValue : dialogMock } ,
438
+ { provide : MAT_DIALOG_DATA , useValue : matDataMock } ,
439
+ { provide : ObjectiveService , useValue : objectiveService } ,
440
+ { provide : QuarterService , useValue : quarterService } ,
441
+ { provide : TeamService , useValue : teamService } ,
442
+ ] ,
443
+ } ) ;
444
+
445
+ let alignmentPossibilities = [
446
+ {
447
+ objectiveId : 1003 ,
448
+ objectiveTitle : 'O - Test Objective' ,
449
+ keyResultAlignmentsDtos : [ ] ,
450
+ } ,
451
+ {
452
+ objectiveId : 1005 ,
453
+ objectiveTitle : 'O - Company will grow' ,
454
+ keyResultAlignmentsDtos : [
455
+ {
456
+ keyResultId : 6 ,
457
+ keyResultTitle : 'K - New structure' ,
458
+ } ,
459
+ ] ,
460
+ } ,
461
+ ] ;
433
462
434
- it ( 'should load correct alignment possibilities' , async ( ) => {
435
463
jest . spyOn ( objectiveService , 'getAlignmentPossibilities' ) . mockReturnValue ( of ( alignmentPossibilities ) ) ;
464
+ fixture = TestBed . createComponent ( ObjectiveFormComponent ) ;
465
+ component = fixture . componentInstance ;
436
466
fixture . detectChanges ( ) ;
437
- component . ngOnInit ( ) ;
467
+ loader = TestbedHarnessEnvironment . loader ( fixture ) ;
468
+ } ) ;
469
+
470
+ it ( 'should create' , ( ) => {
471
+ expect ( component ) . toBeTruthy ( ) ;
472
+ } ) ;
438
473
474
+ it ( 'should load correct alignment possibilities' , async ( ) => {
439
475
let generatedPossibilities = [
440
476
{
441
477
objectiveId : null ,
@@ -470,7 +506,6 @@ describe('ObjectiveDialogComponent', () => {
470
506
matDataMock . objective . objectiveId = 1 ;
471
507
component . objective = objectiveWithAlignment ;
472
508
objectiveService . getFullObjective . mockReturnValue ( of ( objectiveWithAlignment ) ) ;
473
- jest . spyOn ( objectiveService , 'getAlignmentPossibilities' ) . mockReturnValue ( of ( alignmentPossibilities ) ) ;
474
509
fixture . detectChanges ( ) ;
475
510
component . ngOnInit ( ) ;
476
511
@@ -508,7 +543,6 @@ describe('ObjectiveDialogComponent', () => {
508
543
component . objective = objective ;
509
544
component . data . objective . objectiveId = 5 ;
510
545
objectiveService . getFullObjective . mockReturnValue ( of ( objectiveWithAlignment ) ) ;
511
- jest . spyOn ( objectiveService , 'getAlignmentPossibilities' ) . mockReturnValue ( of ( alignmentPossibilities ) ) ;
512
546
fixture . detectChanges ( ) ;
513
547
component . ngOnInit ( ) ;
514
548
@@ -543,7 +577,6 @@ describe('ObjectiveDialogComponent', () => {
543
577
} ) ;
544
578
545
579
it ( 'should load Kein Alignment to alignment possibilities when choosing one alignment' , async ( ) => {
546
- jest . spyOn ( objectiveService , 'getAlignmentPossibilities' ) . mockReturnValue ( of ( alignmentPossibilities ) ) ;
547
580
objectiveService . getFullObjective . mockReturnValue ( of ( objective ) ) ;
548
581
component . objective = objective ;
549
582
component . data . objective . objectiveId = 5 ;
@@ -615,7 +648,7 @@ describe('ObjectiveDialogComponent', () => {
615
648
{ provide : ActivatedRoute , useValue : mockActivatedRoute } ,
616
649
] ,
617
650
} ) ;
618
- jest . spyOn ( objectiveService , 'getAlignmentPossibilities' ) . mockReturnValue ( of ( alignmentPossibilities ) ) ;
651
+ jest . spyOn ( objectiveService , 'getAlignmentPossibilities' ) . mockReturnValue ( of ( [ ] ) ) ;
619
652
fixture = TestBed . createComponent ( ObjectiveFormComponent ) ;
620
653
component = fixture . componentInstance ;
621
654
fixture . detectChanges ( ) ;
0 commit comments