Skip to content

Commit

Permalink
update mock function
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <tygao@amazon.com>
  • Loading branch information
raintygao committed Jun 5, 2024
1 parent 1c8c44c commit be5233d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const setup = ({
}),
reload: jest.fn(),
},
dataSource: rest.dataSource ?? new DataSourceServiceMock(),
dataSource: rest.dataSource ?? new DataSourceServiceMock(false),
},
};
useCoreMock.services.http.put.mockImplementation(() => Promise.resolve());
Expand Down
14 changes: 8 additions & 6 deletions public/services/data_source_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
*/

export class DataSourceServiceMock {
private _isMDSEnabled = false;
private _isMDSEnabled = true;
constructor(isMDSEnabled?: boolean) {
this._isMDSEnabled = isMDSEnabled ?? false;
this._isMDSEnabled = isMDSEnabled ?? true;
}

getDataSourceQuery() {
const dataSourceId = {
dataSourceId: this._isMDSEnabled ? 'data_source_id' : '',
};
const result = this._isMDSEnabled
? {
dataSourceId: '',
}
: {};
return new Promise((resolve) => {
resolve(dataSourceId);
resolve(result);
});
}

Expand Down

0 comments on commit be5233d

Please sign in to comment.