Skip to content

Commit

Permalink
get initial tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Apr 28, 2024
1 parent 290d465 commit 172a2af
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 24 deletions.
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"test": "ng test --browsers=ChromeHeadless --code-coverage --source-map=false"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -36,6 +36,7 @@
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"ng-mocks": "^14.12.2",
"typescript": "~5.4.2"
}
}
16 changes: 3 additions & 13 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { TestBed } from '@angular/core/testing';
import { MessageService } from 'primeng/api';

import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent],
providers: [MessageService],
}).compileComponents();
});

Expand All @@ -13,17 +16,4 @@ describe('AppComponent', () => {
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});

it(`should have the 'contrastinator' title`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('contrastinator');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, contrastinator');
});
});
6 changes: 4 additions & 2 deletions src/app/contrast-chart/contrast-chart.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ describe('ContrastChartComponent', () => {
await TestBed.configureTestingModule({
imports: [ContrastChartComponent]
})
.compileComponents();
.compileComponents();

fixture = TestBed.createComponent(ContrastChartComponent);
component = fixture.componentInstance;
const componentRef = fixture.componentRef;
componentRef.setInput('colors', []);
fixture.detectChanges();
});

Expand Down
10 changes: 7 additions & 3 deletions src/app/header/header.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MessageService } from 'primeng/api';
import { HeaderComponent } from './header.component';

describe('HeaderComponent', () => {
Expand All @@ -8,12 +9,15 @@ describe('HeaderComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HeaderComponent]
imports: [HeaderComponent],
providers: [MessageService],
})
.compileComponents();
.compileComponents();

fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;
const componentRef = fixture.componentRef;
componentRef.setInput('colors', []);
fixture.detectChanges();
});

Expand Down
8 changes: 6 additions & 2 deletions src/app/palette-item/palette-item.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import Color from 'color';
import { PaletteItemComponent } from './palette-item.component';

describe('PaletteItemComponent', () => {
Expand All @@ -10,10 +11,13 @@ describe('PaletteItemComponent', () => {
await TestBed.configureTestingModule({
imports: [PaletteItemComponent]
})
.compileComponents();
.compileComponents();

fixture = TestBed.createComponent(PaletteItemComponent);
component = fixture.componentInstance;
const componentRef = fixture.componentRef;
componentRef.setInput('color', new Color('#000'));
componentRef.setInput('locked', false);
fixture.detectChanges();
});

Expand Down
8 changes: 5 additions & 3 deletions src/app/palette/palette.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MessageService } from 'primeng/api';
import { PaletteComponent } from './palette.component';

describe('PaletteComponent', () => {
Expand All @@ -8,10 +9,11 @@ describe('PaletteComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PaletteComponent]
imports: [PaletteComponent],
providers: [MessageService],
})
.compileComponents();
.compileComponents();

fixture = TestBed.createComponent(PaletteComponent);
component = fixture.componentInstance;
fixture.detectChanges();
Expand Down

0 comments on commit 172a2af

Please sign in to comment.