2019-08-31 20:51:14 -07:00
|
|
|
import Service from '@ember/service';
|
|
|
|
import { TestContext } from 'ember-test-helpers';
|
|
|
|
import { getContext } from '@ember/test-helpers';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a stub service for component integration testing
|
|
|
|
* @param {string} name the name of the service without the service: prefix e.g. 'location-data'
|
|
|
|
* @param {*} [props={}] properties to be stubbed on the service interface
|
|
|
|
*/
|
2020-08-26 15:44:50 -07:00
|
|
|
export const stubService = (name: string, props = {}): void => {
|
2019-08-31 20:51:14 -07:00
|
|
|
const serviceStub = Service.extend(props);
|
|
|
|
const { owner } = getContext() as TestContext; // getContext return type is object, assert TestContext
|
|
|
|
|
|
|
|
owner.register(`service:${name}`, serviceStub);
|
|
|
|
};
|