Skip to content

Commit

Permalink
feat(lib): v4 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NetanelBasal authored and dirkluijk committed Aug 26, 2019
1 parent aaeb7f9 commit 50a599f
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 213 deletions.
31 changes: 15 additions & 16 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions src/app/async/async.component.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ describe('ZippyComponent', () => {
expect(host.query('p')).not.toExist();
});

it('should be truthy', () => {
const host = createHost(`<app-async></app-async>`, { detectChanges: false });
const queryService = host.get(QueryService);
queryService.select.mockReturnValue(of(true));
host.detectChanges();
expect(host.query('p')).toExist();
});
// it('should be truthy', () => {
// const host = createHost(`<app-async></app-async>`, { detectChanges: false });
// const queryService = host.get(QueryService);
// queryService.select.mockReturnValue(of(true));
// host.detectChanges();
// expect(host.query('p')).toExist();
// });
});
23 changes: 13 additions & 10 deletions src/app/auth.service.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import { DateService } from './date.service';
import { createService } from '@netbasal/spectator/jest';

describe('AuthService', () => {
it('should ', () => {
expect(true).toBeTruthy();
});
const spectator = createService({
service: AuthService,
mocks: [DateService]
});
it('should not be logged in', () => {
const dateService = spectator.get(DateService);
dateService.isExpired.mockReturnValue(true);
expect(spectator.service.isLoggedIn()).toBeFalsy();
});
// it('should not be logged in', () => {
// const dateService = spectator.get(DateService);
// dateService.isExpired.mockReturnValue(true);
// expect(spectator.service.isLoggedIn()).toBeFalsy();
// });

it('should be logged in', () => {
const dateService = spectator.get(DateService);
dateService.isExpired.mockReturnValue(false);
expect(spectator.service.isLoggedIn()).toBeTruthy();
});
// it('should be logged in', () => {
// const dateService = spectator.get(DateService);
// dateService.isExpired.mockReturnValue(false);
// expect(spectator.service.isLoggedIn()).toBeTruthy();
// });
});
6 changes: 4 additions & 2 deletions src/app/button/button.component.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe('ButtonComponent', () => {
});

it('should set the title according to the [title]', () => {
spectator = createComponent();
spectator = createComponent({
props: { title: 'Click' }
});

expect(spectator.query('button')).toHaveText('Click');
});
Expand Down Expand Up @@ -53,7 +55,7 @@ describe('ButtonComponent', () => {

const createComponent = createTestComponentFactory<ButtonComponent>({
component: ButtonComponent,
providers: [mockProvider(QueryService)],
componentProviders: [mockProvider(QueryService)],
detectChanges: false
});

Expand Down
10 changes: 3 additions & 7 deletions src/app/hello/hello.component.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ describe('HelloComponent', () => {
const createHost = createHostComponentFactory(HelloComponent);

it('should display the title', () => {
host = createHost(
`
<hello></hello>
`,
true,
{
host = createHost(`<hello></hello> `, {
props: {
title: 'some title',
widthRaw: 20
}
);
});

expect((host.query('div') as HTMLElement).style.width).toBe('20px');

Expand Down
Loading

0 comments on commit 50a599f

Please sign in to comment.