Skip to content

Commit

Permalink
chore(release): 11.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
anh.pham committed Apr 24, 2022
1 parent 3899abf commit eb14beb
Show file tree
Hide file tree
Showing 97 changed files with 3,429 additions and 2,743 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [11.1.2](https://github.com/thymikee/jest-preset-angular/compare/v11.1.1...v11.1.2) (2022-04-24)


### Bug Fixes

* correct deprecation message of `ngcc-jest-processor` ([3899abf](https://github.com/thymikee/jest-preset-angular/commit/3899abf5b886826a00d443db364d7b1fb085122b)), closes [#1411](https://github.com/thymikee/jest-preset-angular/issues/1411)



## [11.1.1](https://github.com/thymikee/jest-preset-angular/compare/v11.0.1...v11.1.1) (2022-02-11)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ import { TestBed, waitForAsync } from '@angular/core/testing';
})
class BarComponent {}

test('templateUrl/styleUrls/styles should work', waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [BarComponent],
});
const fixture = TestBed.createComponent(BarComponent);
fixture.detectChanges();
test(
'templateUrl/styleUrls/styles should work',
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [BarComponent],
});
const fixture = TestBed.createComponent(BarComponent);
fixture.detectChanges();

const elementToFind = fixture.debugElement.nativeElement.querySelector('p');
expect(elementToFind).toBeDefined();
expect(window.getComputedStyle(elementToFind).color).toEqual('');
expect(window.getComputedStyle(elementToFind).fontSize).toEqual('');
}));
const elementToFind = fixture.debugElement.nativeElement.querySelector('p');
expect(elementToFind).toBeDefined();
expect(window.getComputedStyle(elementToFind).color).toEqual('');
expect(window.getComputedStyle(elementToFind).fontSize).toEqual('');
}),
);
17 changes: 10 additions & 7 deletions e2e/async/__tests__/async.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ describe('async with Angular testing apis', () => {
expect(flag).toBe(true);
}));

test('waitForAsync should work', waitForAsync(() => {
let flag = false;
setTimeout(() => {
flag = true;
expect(flag).toBe(true);
}, 100);
}));
test(
'waitForAsync should work',
waitForAsync(() => {
let flag = false;
setTimeout(() => {
flag = true;
expect(flag).toBe(true);
}, 100);
}),
);
});
16 changes: 9 additions & 7 deletions e2e/full-ivy-lib/__tests__/full-ivy-lib.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ describe('Full Ivy library', () => {
let fullIvyComponent: FullIvyComponent;
let fullIvyService: FullIvyService;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [FullIvyModule],
});
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [FullIvyModule],
});

fullIvyComponent = TestBed.createComponent(FullIvyComponent).componentInstance;
fullIvyService = TestBed.inject(FullIvyService);
}));
fullIvyComponent = TestBed.createComponent(FullIvyComponent).componentInstance;
fullIvyService = TestBed.inject(FullIvyService);
}),
);

test('should create the component instance', () => {
expect(fullIvyComponent).toBeDefined();
Expand Down
16 changes: 9 additions & 7 deletions e2e/partial-ivy-lib/__tests__/partial-ivy-lib.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ describe('Partial Ivy library', () => {
let partialIvyComponent: PartialIvyComponent;
let partialIvyService: PartialIvyService;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [PartialIvyModule, PartialIvyTestingModule],
});
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [PartialIvyModule, PartialIvyTestingModule],
});

partialIvyComponent = TestBed.createComponent(PartialIvyComponent).componentInstance;
partialIvyService = TestBed.inject(PartialIvyService);
}));
partialIvyComponent = TestBed.createComponent(PartialIvyComponent).componentInstance;
partialIvyService = TestBed.inject(PartialIvyService);
}),
);

test('should create the component instance', () => {
expect(partialIvyComponent).toBeDefined();
Expand Down
21 changes: 12 additions & 9 deletions e2e/snapshot-serializers/__tests__/foo.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ class FooComponent {
condition2 = false;
}

test('snapshot should work', waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [FooComponent],
});
test(
'snapshot should work',
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [FooComponent],
});

const fixture = TestBed.createComponent(FooComponent);
fixture.detectChanges();
const fixture = TestBed.createComponent(FooComponent);
fixture.detectChanges();

expect(fixture).toMatchSnapshot();
expect(fixture.debugElement.nativeElement).toMatchSnapshot();
}));
expect(fixture).toMatchSnapshot();
expect(fixture.debugElement.nativeElement).toMatchSnapshot();
}),
);
53 changes: 32 additions & 21 deletions examples/example-app-v11/src/app/app-initial.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,38 @@ import { ComponentFixture } from '@angular/core/testing';
import { AppComponent } from './app-initial.component';

describe('AppComponent (initial CLI version)', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
}).compileComponents();
}));
it('should create the app', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Welcome to app!');
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
}).compileComponents();
}),
);
it(
'should create the app',
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
}),
);
it(
`should have as title 'app'`,
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('app');
}),
);
it(
'should render title',
waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Welcome to app!');
}),
);
});

describe('AppComponent (initial CLI version - as it should be)', () => {
Expand Down
14 changes: 8 additions & 6 deletions examples/example-app-v11/src/app/app.component.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ let router: Router;
let location: SpyLocation;

describe('AppComponent & RouterTestingModule', () => {
beforeEach(waitForAsync(() => {
void TestBed.configureTestingModule({
imports: [AppModule, RouterTestingModule.withRoutes(routes)],
providers: [{ provide: HeroService, useClass: TestHeroService }],
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
void TestBed.configureTestingModule({
imports: [AppModule, RouterTestingModule.withRoutes(routes)],
providers: [{ provide: HeroService, useClass: TestHeroService }],
}).compileComponents();
}),
);

it('should navigate to "Dashboard" immediately', fakeAsync(() => {
createComponent();
Expand Down
84 changes: 45 additions & 39 deletions examples/example-app-v11/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,59 @@ let comp: AppComponent;
let fixture: ComponentFixture<AppComponent>;

describe('AppComponent & TestModule', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
RouterLinkDirectiveStub,
BannerStubComponent,
RouterOutletStubComponent,
WelcomeStubComponent,
],
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
});
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
RouterLinkDirectiveStub,
BannerStubComponent,
RouterOutletStubComponent,
WelcomeStubComponent,
],
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
});
}),
);
tests();
});

describe('AppComponent & NO_ERRORS_SCHEMA', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent, BannerStubComponent, RouterLinkDirectiveStub],
schemas: [NO_ERRORS_SCHEMA],
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
});
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AppComponent, BannerStubComponent, RouterLinkDirectiveStub],
schemas: [NO_ERRORS_SCHEMA],
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
});
}),
);
tests();
});

describe('AppComponent & AppModule', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ imports: [AppModule] })
.overrideModule(AppModule, {
remove: { imports: [AppRoutingModule] },
add: { declarations: [RouterLinkDirectiveStub, RouterOutletStubComponent] },
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
});
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({ imports: [AppModule] })
.overrideModule(AppModule, {
remove: { imports: [AppRoutingModule] },
add: { declarations: [RouterLinkDirectiveStub, RouterOutletStubComponent] },
})
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
});
}),
);

tests();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ describe('BannerComponent (initial CLI generated)', () => {
let component: BannerComponent;
let fixture: ComponentFixture<BannerComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ declarations: [BannerComponent] }).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({ declarations: [BannerComponent] }).compileComponents();
}),
);

beforeEach(() => {
fixture = TestBed.createComponent(BannerComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ describe('DashboardHeroComponent when tested directly', () => {
let heroDe: DebugElement;
let heroEl: HTMLElement;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ declarations: [DashboardHeroComponent] }).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({ declarations: [DashboardHeroComponent] }).compileComponents();
}),
);

beforeEach(() => {
fixture = TestBed.createComponent(DashboardHeroComponent);
Expand Down Expand Up @@ -90,9 +92,11 @@ describe('DashboardHeroComponent when inside a test host', () => {
let fixture: ComponentFixture<TestHostComponent>;
let heroEl: HTMLElement;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({ declarations: [DashboardHeroComponent, TestHostComponent] }).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({ declarations: [DashboardHeroComponent, TestHostComponent] }).compileComponents();
}),
);

beforeEach(() => {
fixture = TestBed.createComponent(TestHostComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ describe('DashboardComponent class only', () => {
expect(comp.heroes.length).toEqual(0);
});

it('should HAVE heroes after HeroService gets them', waitForAsync(() => {
comp.ngOnInit();
heroService.lastHeroesResult?.subscribe(() => {
expect(comp.heroes.length).toBeGreaterThan(0);
});
}));
it(
'should HAVE heroes after HeroService gets them',
waitForAsync(() => {
comp.ngOnInit();
heroService.lastHeroesResult?.subscribe(() => {
expect(comp.heroes.length).toBeGreaterThan(0);
});
}),
);

it('should tell ROUTER to navigate by hero id', () => {
const hero: Hero = { id: 42, name: 'Abbracadabra' };
Expand Down
Loading

0 comments on commit eb14beb

Please sign in to comment.