-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Base class for directives and components
Signed-off-by: Michael Gusev <m@sudo.eu>
- Loading branch information
Showing
7 changed files
with
138 additions
and
102 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { EventEmitter } from '@angular/core'; | ||
import { ControlValueAccessor } from '@angular/forms'; | ||
|
||
export class Mock implements ControlValueAccessor { | ||
constructor() { | ||
for (const method of (this as any).__mockedMethods) { | ||
if ((this as any)[method]) { | ||
continue; | ||
} | ||
(this as any)[method] = () => undefined; | ||
} | ||
for (const output of (this as any).__mockedOutputs) { | ||
if ((this as any)[output]) { | ||
continue; | ||
} | ||
(this as any)[output] = new EventEmitter<any>(); | ||
} | ||
} | ||
|
||
__simulateChange = (param: any) => {}; // tslint:disable-line:variable-name | ||
|
||
__simulateTouch = () => {}; // tslint:disable-line:variable-name | ||
|
||
registerOnChange(fn: (value: any) => void): void { | ||
this.__simulateChange = fn; | ||
} | ||
|
||
registerOnTouched(fn: () => void): void { | ||
this.__simulateTouch = fn; | ||
} | ||
|
||
writeValue = () => {}; | ||
} |
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 +1,2 @@ | ||
export * from './mock-of.decorator'; | ||
export * from './Mock'; |
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
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