Skip to content

Commit

Permalink
pick changes from featureAnywhere branch into main (opensearch-projec…
Browse files Browse the repository at this point in the history
…t#542) (opensearch-project#543)

Signed-off-by: Jackie Han <[email protected]>
(cherry picked from commit afa5630)

Co-authored-by: Jackie Han <[email protected]>
  • Loading branch information
1 parent 3eb4fcf commit dc52d68
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
26 changes: 21 additions & 5 deletions public/pages/utils/__tests__/anomalyResultUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import {
getFeatureMissingDataAnnotations,
getFeatureDataPointsForDetector,
parsePureAnomalies,
} from '../anomalyResultUtils';
import { getRandomDetector } from '../../../redux/reducers/__tests__/utils';
import { UNITS, Detector, FeatureAttributes } from '../../../models/interfaces';

import {
UNITS,
Detector,
FeatureAttributes,
AnomalyData,
} from '../../../models/interfaces';
import { ANOMALY_RESULT_SUMMARY, PARSED_ANOMALIES } from './constants';

describe('anomalyResultUtils', () => {
let randomDetector_20_min: Detector;
let randomDetector_20_sec: Detector;
Expand Down Expand Up @@ -43,7 +50,7 @@ describe('anomalyResultUtils', () => {
},
] as FeatureAttributes[],
};

randomDetector_20_sec = {
...getRandomDetector(true),
detectionInterval: {
Expand Down Expand Up @@ -563,4 +570,13 @@ describe('anomalyResultUtils', () => {
).toEqual([]);
});
});
});

describe('parsePureAnomalies()', () => {
test('parse anomalies', async () => {
const parsedPureAnomalies: AnomalyData[] = await parsePureAnomalies(
ANOMALY_RESULT_SUMMARY
);
expect(parsedPureAnomalies).toStrictEqual(PARSED_ANOMALIES);
});
});
});
14 changes: 12 additions & 2 deletions test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

module.exports = {
rootDir: '../',
setupFiles: ['<rootDir>/test/polyfills.ts', '<rootDir>/test/setupTests.ts'],
Expand Down Expand Up @@ -44,4 +44,14 @@ module.exports = {
testPathIgnorePatterns: ['<rootDir>/build/', '<rootDir>/node_modules/'],
transformIgnorePatterns: ['<rootDir>/node_modules'],
globalSetup: '<rootDir>/global-setup.js',
};

/**
* This configuration specifies different file extensions
* and the corresponding transformers to be used
*/
transform: {
'\\.[jt]sx?$': 'babel-jest',
'^.+\\.svg$': '<rootDir>/test/mocks/transformMock.ts',
'^.+\\.html$': '<rootDir>/test/mocks/transformMock.ts',
},
};

0 comments on commit dc52d68

Please sign in to comment.