Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xelaint committed Jan 16, 2024
1 parent a202eae commit 1d09315
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import { RouterTestingModule } from '@angular/router/testing';

import { DaffTreeModule } from '@daffodil/design/tree';

import { DaffioGuidesNavComponent } from './guides-nav.component';
import { DaffioDocsPackagesListComponent } from './packages-list.component';

describe('DaffioGuidesNavComponent', () => {
let component: DaffioGuidesNavComponent;
let fixture: ComponentFixture<DaffioGuidesNavComponent>;
describe('DaffioDocsPackagesListComponent', () => {
let component: DaffioDocsPackagesListComponent;
let fixture: ComponentFixture<DaffioDocsPackagesListComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffioGuidesNavComponent,
DaffioDocsPackagesListComponent,
],
imports: [
RouterTestingModule,
Expand All @@ -30,7 +30,7 @@ describe('DaffioGuidesNavComponent', () => {
}));

beforeEach(() => {
fixture = TestBed.createComponent(DaffioGuidesNavComponent);
fixture = TestBed.createComponent(DaffioDocsPackagesListComponent);
component = fixture.componentInstance;
const guideWithoutChildren = {
id: 'id2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,35 @@ import {
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffTreeModule } from '@daffodil/design/tree';
import { DaffioDocsPackagesListContainer } from './packages-list.component';

import { DaffioGuidesNavComponent } from './guides-nav.component';

describe('DaffioGuidesNavComponent', () => {
let component: DaffioGuidesNavComponent;
let fixture: ComponentFixture<DaffioGuidesNavComponent>;
describe('DaffioDocsPackagesListContainer', () => {
let component: DaffioDocsPackagesListContainer;
let fixture: ComponentFixture<DaffioDocsPackagesListContainer>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffioGuidesNavComponent,
DaffioDocsPackagesListContainer,
],
imports: [
RouterTestingModule,
NoopAnimationsModule,
DaffTreeModule,
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DaffioGuidesNavComponent);
fixture = TestBed.createComponent(DaffioDocsPackagesListContainer);
component = fixture.componentInstance;
const guideWithoutChildren = {
id: 'id2',
title: 'title2',
children: [],
};
const guideWithChildren = {
id: 'id3',
title: 'title3',
children: [
{
id: 'id4',
title: 'title4',
children: [],
},
],
};

component.guideList = {
id: 'root',
title: 'root',
children: [
guideWithoutChildren,
guideWithChildren,
],
};
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should render an anchor tag when the guide child has no children', () => {
const anchorTags = fixture.debugElement.queryAll(By.css('a'));
expect(anchorTags.length).toEqual(1);
const buttons = fixture.debugElement.queryAll(By.css('button'));
expect(buttons.length).toEqual(1);
console.log(fixture.debugElement.nativeElement.innerHTML);
});
});

0 comments on commit 1d09315

Please sign in to comment.