mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-01 05:47:17 +00:00
16 lines
644 B
TypeScript
16 lines
644 B
TypeScript
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
|
|
*/
|
|
export const stubService = (name: string, props = {}) => {
|
|
const serviceStub = Service.extend(props);
|
|
const { owner } = getContext() as TestContext; // getContext return type is object, assert TestContext
|
|
|
|
owner.register(`service:${name}`, serviceStub);
|
|
};
|