Skip to content

Commit

Permalink
feat(core): remove ability to provide configs via FeatureServiceRegistry
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The option `featureServiceConfigs` has been removed
from the options of `createFeatureHub` and from the options of the
`FeatureServiceRegistry` constructor. The `env` that is passed to a
Feature Service's `create` method does not include a `config` property
anymore. If a Feature Service must be configured, a factory function
that accepts options, and that returns a Feature Service definition,
should be used instead, see @feature-hub/async-ssr-manager for an
example.
  • Loading branch information
unstubbable committed Jun 5, 2019
1 parent 9536ef7 commit 683f4b7
Show file tree
Hide file tree
Showing 27 changed files with 259 additions and 334 deletions.
8 changes: 2 additions & 6 deletions packages/async-ssr-manager/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function simulateAsyncOperation(result: number): Promise<number> {
}

describe('defineAsyncSsrManager', () => {
let mockEnv: FeatureServiceEnvironment<undefined, {}>;
let mockEnv: FeatureServiceEnvironment<{}>;

let asyncSsrManagerDefinition: FeatureServiceProviderDefinition<
SharedAsyncSsrManager
Expand All @@ -34,10 +34,7 @@ describe('defineAsyncSsrManager', () => {
});

beforeEach(() => {
mockEnv = {
config: undefined,
featureServices: {'s2:logger': stubbedLogger}
};
mockEnv = {featureServices: {'s2:logger': stubbedLogger}};
});

it('creates an Async SSR Manager definition', () => {
Expand Down Expand Up @@ -322,7 +319,6 @@ describe('defineAsyncSsrManager', () => {
asyncSsrManagerDefinition = defineAsyncSsrManager();

asyncSsrManagerBinder = asyncSsrManagerDefinition.create({
config: undefined,
featureServices: {}
})['1.0.0'];
});
Expand Down
20 changes: 1 addition & 19 deletions packages/core/src/__tests__/create-feature-hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,6 @@ describe('createFeatureHub()', () => {
});
});

describe('and with Feature Service configs', () => {
beforeEach(() => {
featureHubOptions = {
...featureHubOptions,
featureServiceConfigs: {'test:feature-service': 'mockConfig'}
};
});

it('registers and creates the Feature Services, using the relevant config', () => {
createFeatureHub('test:integrator', featureHubOptions);

expect(mockFeatureServiceCreate).toHaveBeenCalledWith({
config: 'mockConfig',
featureServices: {}
});
});
});

describe('and with provided externals', () => {
beforeEach(() => {
featureHubOptions = {...featureHubOptions, providedExternals: {}};
Expand Down Expand Up @@ -284,7 +266,7 @@ describe('createFeatureHub()', () => {

expectedLogCalls = [
[
'The Feature Service "test:feature-service" has been successfully registered by consumer "test:integrator".'
'The Feature Service "test:feature-service" has been successfully registered by registrant "test:integrator".'
],
['The Feature App "test:feature-app" has been successfully created.']
];
Expand Down
25 changes: 13 additions & 12 deletions packages/core/src/__tests__/feature-app-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('FeatureAppManager', () => {
});

expect(mockFeatureServiceRegistry.bindFeatureServices.mock.calls).toEqual(
[[mockFeatureAppDefinition, idSpecifier]]
[[mockFeatureAppDefinition, 'testId:testIdSpecifier']]
);

const {featureServices} = mockFeatureServicesBinding;
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('FeatureAppManager', () => {
const {featureServices} = mockFeatureServicesBinding;

expect(mockBeforeCreate.mock.calls).toEqual([
['testId', featureServices]
[mockFeatureAppDefinition.id, featureServices]
]);
});

Expand All @@ -226,7 +226,7 @@ describe('FeatureAppManager', () => {
const {featureServices} = mockFeatureServicesBinding;

expect(mockBeforeCreate.mock.calls).toEqual([
['testId', featureServices]
[mockFeatureAppDefinition.id, featureServices]
]);
});
});
Expand All @@ -250,7 +250,7 @@ describe('FeatureAppManager', () => {
const {featureServices} = mockFeatureServicesBinding;

expect(mockBeforeCreate.mock.calls).toEqual([
[`testId:${idSpecifier}`, featureServices]
[`${mockFeatureAppDefinition.id}:${idSpecifier}`, featureServices]
]);
});
});
Expand Down Expand Up @@ -411,19 +411,20 @@ describe('FeatureAppManager', () => {
});

it("registers the Feature App's own Feature Services before binding its required Feature Services", () => {
featureAppManager.getFeatureAppScope(mockFeatureAppDefinition, {
idSpecifier: 'testIdSpecifier'
});
featureAppManager.getFeatureAppScope(mockFeatureAppDefinition);

expect(
mockFeatureServiceRegistry.registerFeatureServices.mock.calls
).toEqual([
[mockFeatureAppDefinition.ownFeatureServiceDefinitions, 'testId']
[
mockFeatureAppDefinition.ownFeatureServiceDefinitions,
mockFeatureAppDefinition.id
]
]);

expect(
mockFeatureServiceRegistry.bindFeatureServices.mock.calls
).toEqual([[mockFeatureAppDefinition, 'testIdSpecifier']]);
).toEqual([[mockFeatureAppDefinition, mockFeatureAppDefinition.id]]);

expect(featureServiceRegistryMethodCalls).toEqual([
'registerFeatureServices',
Expand Down Expand Up @@ -453,7 +454,7 @@ describe('FeatureAppManager', () => {
const {featureServices} = mockFeatureServicesBinding;

expect(mockBeforeCreate.mock.calls).toEqual([
['testId', featureServices]
[mockFeatureAppDefinition.id, featureServices]
]);
});

Expand All @@ -480,8 +481,8 @@ describe('FeatureAppManager', () => {
const {featureServices} = mockFeatureServicesBinding;

expect(mockBeforeCreate.mock.calls).toEqual([
['testId', featureServices],
['testId', featureServices]
[mockFeatureAppDefinition.id, featureServices],
[mockFeatureAppDefinition.id, featureServices]
]);
});
});
Expand Down
Loading

0 comments on commit 683f4b7

Please sign in to comment.