Commit 3a1b2c54 authored by Maya Metodieva's avatar Maya Metodieva
Browse files

Added unit tests

parent 2d825668
No related merge requests found
Showing with 478 additions and 302 deletions
+478 -302
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
node: 'current'
}
}],
'@babel/preset-typescript',
],
plugins: [
['@babel/plugin-proposal-decorators', {
legacy: true
}]
]
};
......@@ -3,9 +3,9 @@ import { Util } from "./util";
describe('add new student', () => {
it('success', () => {
Util.performSuccessfulLogin('login-button', 'maya', 'pizza', 'Administrator', cy);
Util.createStudent('testStudent', '25', 'testStudent', '123', cy);
Util.createStudent('Test', '25', 'Test', '123', cy);
cy.get('[id=logout-button]').click();
Util.performSuccessfulLogin('login-button', 'testStudent', '123', 'Student', cy);
Util.performSuccessfulLogin('login-button', 'Test', '123', 'Student', cy);
});
});
......
......@@ -3,7 +3,7 @@
* https://jestjs.io/docs/configuration
*/
import type {Config} from 'jest';
import type { Config } from 'jest';
const config: Config = {
// All imported modules in your tests should be mocked automatically
......@@ -73,9 +73,9 @@ const config: Config = {
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
moduleDirectories: [
"node_modules", "<rootDir>"
],
// An array of file extensions your modules use
// moduleFileExtensions: [
......@@ -90,7 +90,9 @@ const config: Config = {
// ],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},
// moduleNameMapper: {
// "src/(.*)": "<rootDir>/src/$1"
// },
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
......@@ -101,8 +103,8 @@ const config: Config = {
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
// preset: undefined,
//A preset that is used as a base for Jest's configuration
preset: 'jest-preset-angular',
// Run tests from one or more projects
// projects: undefined,
......@@ -137,7 +139,9 @@ const config: Config = {
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
setupFilesAfterEnv: [
"<rootDir>/setup-jest.ts"
],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
......@@ -161,9 +165,7 @@ const config: Config = {
// ],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],
testPathIgnorePatterns: ['<rootDir>/cypress/'],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
......
This diff is collapsed.
......@@ -32,12 +32,15 @@
"@angular-devkit/build-angular": "^16.2.0",
"@angular/cli": "~16.2.0",
"@angular/compiler-cli": "^16.2.0",
"@babel/plugin-proposal-decorators": "^7.22.10",
"@babel/preset-typescript": "^7.22.11",
"@jest/globals": "^29.6.4",
"@types/jasmine": "~4.3.0",
"@types/jest": "^29.5.4",
"cypress": "^12.17.4",
"jasmine-core": "~4.6.0",
"jest": "^29.6.4",
"jest-preset-angular": "^13.1.1",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
......
import 'jest-preset-angular/setup-jest';
\ No newline at end of file
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [AppComponent]
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'student-management-frontend'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('student-management-frontend');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain('student-management-frontend app is running!');
});
});
......@@ -23,7 +23,7 @@ import { CourseInfoComponent } from 'src/app/components/common/course-info/cours
import { CourseModificationComponent } from 'src/app/components/common/course-modification/course-modification.component';
import { TableComponent } from 'src/app/components/common/table/table.component';
import { LandingPageComponent } from 'src/app/components/pages/landing-page/landing-page.component';
import { SchoolObjectModificationComponent } from './components/common/school-objects/school-object-modification/school-object-modification.component';
import { SchoolObjectModificationComponent } from 'src/app/components/common/school-objects/school-object-modification/school-object-modification.component';
import { LetterGradePipe } from './pipes/letter-grade.pipe';
import { UserDetailsComponent } from './components/pages/user-details/user-details.component';
......
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CourseAvgGradeComponent } from './course-avg-grade.component';
describe('CourseAvgGradeComponent', () => {
let component: CourseAvgGradeComponent;
let fixture: ComponentFixture<CourseAvgGradeComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [CourseAvgGradeComponent]
});
fixture = TestBed.createComponent(CourseAvgGradeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StudentAvgGradeComponent } from './student-avg-grade.component';
describe('StudentAvgGradeComponent', () => {
let component: StudentAvgGradeComponent;
let fixture: ComponentFixture<StudentAvgGradeComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StudentAvgGradeComponent]
});
fixture = TestBed.createComponent(StudentAvgGradeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CourseInfoComponent } from './course-info.component';
describe('CourseInfoComponent', () => {
let component: CourseInfoComponent;
let fixture: ComponentFixture<CourseInfoComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [CourseInfoComponent]
});
fixture = TestBed.createComponent(CourseInfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CourseModificationComponent } from './course-modification.component';
describe('CourseModificationComponent', () => {
let component: CourseModificationComponent;
let fixture: ComponentFixture<CourseModificationComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [CourseModificationComponent]
});
fixture = TestBed.createComponent(CourseModificationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CourseComponent } from './course.component';
describe('CourseComponent', () => {
let component: CourseComponent;
let fixture: ComponentFixture<CourseComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [CourseComponent]
});
fixture = TestBed.createComponent(CourseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoursesListComponent } from './courses-list.component';
describe('CoursesListComponent', () => {
let component: CoursesListComponent;
let fixture: ComponentFixture<CoursesListComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [CoursesListComponent]
});
fixture = TestBed.createComponent(CoursesListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavbarComponent } from './navbar.component';
describe('NavbarComponent', () => {
let component: NavbarComponent;
let fixture: ComponentFixture<NavbarComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NavbarComponent]
});
fixture = TestBed.createComponent(NavbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SchoolObjectCreationComponent } from './school-object-creation.component';
describe('SchoolObjectCreationComponent', () => {
let component: SchoolObjectCreationComponent;
let fixture: ComponentFixture<SchoolObjectCreationComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SchoolObjectCreationComponent]
});
fixture = TestBed.createComponent(SchoolObjectCreationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SchoolObjectModificationComponent } from './school-object-modification.component';
describe('SchoolObjectModificationComponent', () => {
let component: SchoolObjectModificationComponent;
let fixture: ComponentFixture<SchoolObjectModificationComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SchoolObjectModificationComponent]
});
fixture = TestBed.createComponent(SchoolObjectModificationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TableComponent } from './table.component';
describe('TableComponent', () => {
let component: TableComponent;
let fixture: ComponentFixture<TableComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TableComponent]
});
fixture = TestBed.createComponent(TableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ButtonComponent } from './button.component';
describe('ButtonComponent', () => {
let component: ButtonComponent;
let fixture: ComponentFixture<ButtonComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ButtonComponent]
});
fixture = TestBed.createComponent(ButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ObjectCreationModalComponent } from './object-creation-modal.component';
describe('ObjectCreationModalComponent', () => {
let component: ObjectCreationModalComponent;
let fixture: ComponentFixture<ObjectCreationModalComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ObjectCreationModalComponent]
});
fixture = TestBed.createComponent(ObjectCreationModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment