-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3684241
commit aaeb7f9
Showing
37 changed files
with
231 additions
and
592 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,9 @@ | ||
/** | ||
* @license | ||
* Copyright Netanel Basal. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https:/NetanelBasal/spectator/blob/master/LICENSE | ||
*/ | ||
|
||
import { Type } from '@angular/core'; | ||
import { SpectatorWithHost as BaseSpectatorWithHost, createHostComponentFactory as baseCreateHostComponentFactory, HostComponent, SpectatorOptions, isType, Token } from '@netbasal/spectator'; | ||
|
||
import { mockProvider, SpyObject } from './mock'; | ||
|
||
export class SpectatorWithHost<C, H = HostComponent> extends BaseSpectatorWithHost<C, H> { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get<T>(type: Token<T>, fromComponentInjector = false): T & SpyObject<T> { | ||
return super.get(type, fromComponentInjector) as T & SpyObject<T>; | ||
} | ||
} | ||
import { createHostComponentFactory as baseCreateHostComponentFactory, HostComponent, SpectatorOptions, SpectatorWithHost as BaseSpectatorWithHost } from '@netbasal/spectator'; | ||
import { CreateComponentOptions } from '../../src/lib/types'; | ||
|
||
export function createHostComponentFactory<C, H = HostComponent>(options: SpectatorOptions<C, H> | Type<C>): (template: string, detectChanges?: boolean, complexInputs?: Partial<C>) => SpectatorWithHost<C, H> { | ||
if (!isType(options)) { | ||
options.providers = options.providers || []; | ||
(options.mocks || []).forEach(type => options.providers.push(mockProvider(type))); | ||
options.mocks = []; | ||
} | ||
export class SpectatorWithHost<C, H = HostComponent> extends BaseSpectatorWithHost<C, H> {} | ||
|
||
return baseCreateHostComponentFactory(options) as (template: string, detectChanges?: boolean, complexInputs?: Partial<C>) => SpectatorWithHost<C, H>; | ||
export function createHostComponentFactory<Component, Host = HostComponent>(options: SpectatorOptions<Component, Host> | Type<Component>): (template: string, options?: CreateComponentOptions<Component>) => SpectatorWithHost<Component, Host> { | ||
return baseCreateHostComponentFactory(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,3 @@ | ||
/** | ||
* @license | ||
* Copyright Netanel Basal. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https:/NetanelBasal/spectator/blob/master/LICENSE | ||
*/ | ||
import { Spectator as BaseSpectator } from '@netbasal/spectator'; | ||
|
||
import { Spectator as BaseSpectator, Token } from '@netbasal/spectator'; | ||
|
||
import { SpyObject } from './mock'; | ||
|
||
export class Spectator<C> extends BaseSpectator<C> { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
get<T>(type: Token<T> | Token<any>, fromComponentInjector = false): T & SpyObject<T> { | ||
return super.get(type, fromComponentInjector) as T & SpyObject<T>; | ||
} | ||
} | ||
export class Spectator<C> extends BaseSpectator<C> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,11 @@ | ||
/** | ||
* @license | ||
* Copyright Netanel Basal. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https:/NetanelBasal/spectator/blob/master/LICENSE | ||
*/ | ||
|
||
import { Type } from '@angular/core'; | ||
import { SpectatorService as BaseSpectatorService, createService as baseCreateService, isType, ServiceParams, Token } from '@netbasal/spectator'; | ||
|
||
import { mockProvider, SpyObject } from './mock'; | ||
import { createService as baseCreateService, ServiceParams, SpectatorService as BaseSpectatorService, Token } from '@netbasal/spectator'; | ||
import { SpyObject } from './mock'; | ||
|
||
export interface SpectatorService<S> extends BaseSpectatorService<S> { | ||
get<T>(token: Token<T> | Token<any>): T & SpyObject<T>; | ||
} | ||
|
||
export function createService<S>(options: ServiceParams<S> | Type<S>): SpectatorService<S> { | ||
if (!isType(options)) { | ||
options.providers = options.providers || []; | ||
(options.mocks || []).forEach(type => options.providers.push(mockProvider(type))); | ||
options.mocks = []; | ||
options.declarations = options.declarations || []; | ||
options.entryComponents = options.entryComponents || []; | ||
} | ||
|
||
return baseCreateService(options) as SpectatorService<S>; | ||
export function createService<Service>(options: ServiceParams<Service> | Type<Service>): SpectatorService<Service> { | ||
return baseCreateService(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
/** | ||
* @license | ||
* Copyright Netanel Basal. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https:/NetanelBasal/spectator/blob/master/LICENSE | ||
*/ | ||
|
||
import { createTestComponentFactory as baseCreateTestComponentFactory, SpectatorOptions, isType } from '@netbasal/spectator'; | ||
import { mockProvider } from './mock'; | ||
import { createTestComponentFactory as baseCreateTestComponentFactory, SpectatorOptions } from '@netbasal/spectator'; | ||
import { Type } from '@angular/core'; | ||
import { Spectator } from './internals'; | ||
import { CreateComponentOptions } from '../../src/lib/types'; | ||
|
||
/** | ||
* Create factory-function for tested component | ||
* @param component - testedType | ||
* @param shallow - use NO_ERRORS_SCHEMA | ||
* @param moduleMetadata | ||
*/ | ||
export function createTestComponentFactory<T>(options: SpectatorOptions<T> | Type<T>): (componentParameters?: Partial<T>, detectChanges?: boolean) => Spectator<T> { | ||
if (!isType(options)) { | ||
options.providers = options.providers || []; | ||
(options.mocks || []).forEach(type => options.providers.push(mockProvider(type))); | ||
options.mocks = []; | ||
} | ||
|
||
return baseCreateTestComponentFactory(options) as (componentParameters?: Partial<T>, detectChanges?: boolean) => Spectator<T>; | ||
export function createTestComponentFactory<Component>(typeOrOptions: SpectatorOptions<Component> | Type<Component>): (options?: CreateComponentOptions<Component>) => Spectator<Component> { | ||
return baseCreateTestComponentFactory(typeOrOptions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.