getsaf / shallow-render

Angular testing made easy with shallow rendering and easy mocking. https://getsaf.github.io/shallow-render
MIT License
273 stars 25 forks source link

feat: Allow directly mocking injection tokens #154

Closed getsaf closed 4 years ago

getsaf commented 4 years ago

Addresses deficiencies noted in #153

This allows mocking injection tokens directly like:

const STRING_TOKEN = new InjectionToken<string>('A string injection token');
const FUNCTION_TOKEN = new InjectionToken<() => string>('A function injection token');

// Can now be mocked with:
shallow
  .mock(STRING_TOKEN, 'mocked value')
  .mock(FUNCTION_TOKEN, () => 'mocked function return');