Skip to content

Instantly share code, notes, and snippets.

@cnunciato
Created October 5, 2016 00:49
Show Gist options
  • Save cnunciato/5d8f5d20c42ae76663e2789278e8890e to your computer and use it in GitHub Desktop.
Save cnunciato/5d8f5d20c42ae76663e2789278e8890e to your computer and use it in GitHub Desktop.
Mock an Angular 2 Component with an Empty Template
import { Component } from '@angular/core';
/**
* Examples:
* MockComponent({ selector: 'node-list-table' });
* MockComponent({ selector: 'node-rollup', inputs: ['someprop', 'otherprop'] });
*
* See https://angular.io/docs/ts/latest/api/core/index/Component-decorator.html for a list
* of supported properties.
*/
export function MockComponent(options: Component): Component {
let metadata: Component = {
selector: options.selector,
template: options.template || '',
inputs: options.inputs,
outputs: options.outputs
};
return Component(metadata)(class _ {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment