Skip to content

Commit

Permalink
test(unit): clean spec components from nucleus-angular
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasferreiralimax committed Oct 21, 2024
1 parent f20f243 commit 0b9eb18
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { DarkmodeComponent } from 'darkmode-angular';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { AppHeaderComponent } from './components/app-header/app-header.component';
import { ModalinstallComponent } from './components/modal-install/modal-install.component';
import { AppFooterComponent } from './components/app-footer/app-footer.component';
import { UpWindowAngularModule } from '../../projects/up-window-angular/src/public-api';
import { By } from '@angular/platform-browser';

Expand All @@ -14,15 +9,7 @@ describe('AppComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
FormsModule,
AppComponent,
DarkmodeComponent,
AppHeaderComponent,
ModalinstallComponent,
UpWindowAngularModule,
AppFooterComponent
],
imports: [AppComponent, UpWindowAngularModule],
}).compileComponents();
}));

Expand All @@ -36,41 +23,8 @@ describe('AppComponent', () => {
expect(component).toBeTruthy();
});

it('should render app-darkmode component with hiddenLabel true', () => {
const darkModeComponent = fixture.debugElement.query(By.directive(DarkmodeComponent));
expect(darkModeComponent).toBeTruthy();
expect(darkModeComponent.componentInstance.hiddenLabel).toBe(true);
});

it('should render app-header component', () => {
const headerComponent = fixture.debugElement.query(By.directive(AppHeaderComponent));
expect(headerComponent).toBeTruthy();
});

it('should render main with class main', () => {
const mainElement = fixture.debugElement.query(By.css('main.main'));
expect(mainElement).toBeTruthy();
});

it('should render app-modal-install component with correct properties', () => {
component.isModalActive = true;
fixture.detectChanges();
const modalComponent = fixture.debugElement.query(By.directive(ModalinstallComponent));
expect(modalComponent).toBeTruthy();
expect(modalComponent.componentInstance.active).toBe(true);
});

it('should call openModal when button with class button-modal is clicked', () => {
spyOn(component, 'openModal');
const buttonElement = fixture.debugElement.query(By.css('.button-modal'));
buttonElement.nativeElement.click();
expect(component.openModal).toHaveBeenCalled();
});

it('should render correct codeString in code-wrapper element', () => {
component.codeString = 'npm install up-window-angular';
fixture.detectChanges();
const codeWrapperElement = fixture.debugElement.query(By.css('.code-wrapper'));
expect(codeWrapperElement.nativeElement.textContent.trim()).toBe('npm install up-window-angular');
});
});

0 comments on commit 0b9eb18

Please sign in to comment.