Skip to content

Commit

Permalink
fix(mocks): readd deprecated mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Netanel Basal committed Sep 1, 2019
1 parent 8c08fbe commit a358f13
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions projects/spectator/src/lib/deprecated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, EventEmitter, Directive } from '@angular/core';

export function MockComponentDeprecated(options: Component): Component {
const metadata: Component = {
selector: options.selector,
template: options.template || '',
inputs: options.inputs,
outputs: options.outputs || [],
exportAs: options.exportAs || ''
};

class Mock {}

(metadata as any).outputs.forEach(method => {
Mock.prototype[method] = new EventEmitter<any>();
});

return Component(metadata)(Mock as any);
}

export function MockDirectiveDeprecated(options: Directive): Directive {
const metadata: Directive = {
selector: options.selector,
inputs: options.inputs,
outputs: options.outputs || [],
exportAs: options.exportAs || ''
};

class Mock {}

(metadata as any).outputs.forEach(method => {
Mock.prototype[method] = new EventEmitter<any>();
});

return Directive(metadata)(Mock as any);
}
1 change: 1 addition & 0 deletions projects/spectator/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ export * from './lib/types';
export { typeInElement } from './lib/type-in-element';
export { defineGlobalsInjections } from './lib/globals-injections';
export { dispatchEvent, dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent, dispatchTouchEvent } from './lib/dispatch-events';
export { MockComponentDeprecated, MockDirectiveDeprecated } from './lib/deprecated';

0 comments on commit a358f13

Please sign in to comment.