Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
Signed-off-by: Bandini Bhopi <bandinib@amazon.com>
  • Loading branch information
bandinib-amzn committed Feb 13, 2024
1 parent 930eb55 commit 6933ea0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {
AuthenticationMethodRegistery,
AuthenticationMethod,
} from './authentication_methods_registry';
import { AuthenticationMethodRegistery } from './authentication_methods_registry';
import React from 'react';

export const createAuthenticationMethod = (
authMethod: Partial<AuthenticationMethod>
): AuthenticationMethod => ({
name: 'unknown',
credentialForm: React.createElement('div', {}, 'Hello, world!'),
credentialSourceOption: {
value: 'unknown',
},
...authMethod,
});
import { createAuthenticationMethod } from '../mocks';

describe('AuthenticationMethodRegistery', () => {
let registry: AuthenticationMethodRegistery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ export {
AuthenticationMethod,
AuthenticationMethodRegistery,
} from './authentication_methods_registry';

export { createAuthenticationMethod } from './authentication_methods_registry.test';
13 changes: 13 additions & 0 deletions src/plugins/data_source_management/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { throwError } from 'rxjs';
import { SavedObjectsClientContract } from 'opensearch-dashboards/public';
import { AuthType } from './types';
Expand All @@ -14,6 +15,7 @@ import {
} from './plugin';
import { managementPluginMock } from '../../management/public/mocks';
import { mockManagementPlugin as indexPatternManagementPluginMock } from '../../index_pattern_management/public/mocks';
import { AuthenticationMethod } from './auth_registry';

/* Mock Types */

Expand Down Expand Up @@ -225,3 +227,14 @@ export const testDataSourceManagementPlugin = (
};
return { setup, doStart };
};

export const createAuthenticationMethod = (
authMethod: Partial<AuthenticationMethod>
): AuthenticationMethod => ({
name: 'unknown',
credentialForm: React.createElement('div', {}, 'Hello, world!'),
credentialSourceOption: {
value: 'unknown',
},
...authMethod,
});
3 changes: 1 addition & 2 deletions src/plugins/data_source_management/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*/
import { coreMock } from '../../../core/public/mocks';
import { DataSourceManagementPluginStart } from './plugin';
import { testDataSourceManagementPlugin } from './mocks';
import { createAuthenticationMethod } from './auth_registry';
import { testDataSourceManagementPlugin, createAuthenticationMethod } from './mocks';

describe('#dataSourceManagement', () => {
let coreSetup: any;
Expand Down

0 comments on commit 6933ea0

Please sign in to comment.