-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathedit-graph-advanced.component.spec.ts
More file actions
90 lines (83 loc) · 3.62 KB
/
Copy pathedit-graph-advanced.component.spec.ts
File metadata and controls
90 lines (83 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProjectLocale } from '../../../../../app/domain/projectLocale';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
import { NotebookService } from '../../../services/notebookService';
import { TeacherNodeService } from '../../../services/teacherNodeService';
import { TeacherProjectService } from '../../../services/teacherProjectService';
import { TeacherProjectTranslationService } from '../../../services/teacherProjectTranslationService';
import { GraphContent } from '../GraphContent';
import { EditGraphAdvancedComponent } from './edit-graph-advanced.component';
let component: EditGraphAdvancedComponent;
let fixture: ComponentFixture<EditGraphAdvancedComponent>;
describe('EditGraphAdvancedComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [EditGraphAdvancedComponent, StudentTeacherCommonServicesModule],
providers: [
TeacherNodeService,
TeacherProjectService,
TeacherProjectTranslationService,
provideHttpClient(withInterceptorsFromDi())
]
}).compileComponents();
});
beforeEach(() => {
const projectService = TestBed.inject(TeacherProjectService);
spyOn(projectService, 'getComponent').and.returnValue({
xAxis: {},
yAxis: {}
} as GraphContent);
spyOn(TestBed.inject(TeacherProjectService), 'getProject').and.returnValue({});
spyOn(projectService, 'getLocale').and.returnValue(new ProjectLocale({ default: 'en-US' }));
spyOn(projectService, 'isDefaultLocale').and.returnValue(true);
spyOn(TestBed.inject(NotebookService), 'isNotebookEnabled').and.returnValue(true);
fixture = TestBed.createComponent(EditGraphAdvancedComponent);
component = fixture.componentInstance;
spyOn(component, 'setShowSubmitButtonValue').and.callFake(() => {});
spyOn(component, 'componentChanged').and.callFake(() => {});
fixture.detectChanges();
});
addXAxisPlotLine();
addYAxisPlotLine();
deleteXAxisPlotLine();
deleteYAxisPlotLine();
});
function addXAxisPlotLine() {
describe('addXAxisPlotLine', () => {
it('should add x axis plot line', () => {
component.addXAxisPlotLine();
expect(component.componentContent.xAxis.plotLines.length).toEqual(1);
expect(component.componentContent.xAxis.plotLines[0].label.text).toEqual('');
expect(component.componentContent.xAxis.plotLines[0].label.verticalAlign).toEqual('bottom');
expect(component.componentContent.xAxis.plotLines[0].label.textAlign).toEqual('right');
});
});
}
function addYAxisPlotLine() {
describe('addYAxisPlotLine', () => {
it('should add y axis plot line', () => {
component.addYAxisPlotLine();
expect(component.componentContent.yAxis.plotLines.length).toEqual(1);
expect(component.componentContent.yAxis.plotLines[0].label.text).toEqual('');
});
});
}
function deleteXAxisPlotLine() {
describe('deleteXAxisPlotLine', () => {
it('should delete x axis plot line', () => {
component.componentContent.xAxis.plotLines = [{}, {}];
component.deleteXAxisPlotLine(0);
expect(component.componentContent.xAxis.plotLines.length).toEqual(1);
});
});
}
function deleteYAxisPlotLine() {
describe('deleteYAxisPlotLine', () => {
it('should delete y axis plot line', () => {
component.componentContent.yAxis.plotLines = [{}, {}];
component.deleteYAxisPlotLine(0);
expect(component.componentContent.yAxis.plotLines.length).toEqual(1);
});
});
}