From 462c082593466d571ea0820c7fe75875763c9876 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Tue, 3 Dec 2024 23:24:32 +0700 Subject: [PATCH] Create anomalyDetection.test.js --- tests/anomalyDetection.test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/anomalyDetection.test.js diff --git a/tests/anomalyDetection.test.js b/tests/anomalyDetection.test.js new file mode 100644 index 000000000..9ce0b4207 --- /dev/null +++ b/tests/anomalyDetection.test.js @@ -0,0 +1,27 @@ +// anomalyDetection.test.js + +import AnomalyDetection from './anomalyDetection'; // Assuming you have an AnomalyDetection class/module + +describe('Anomaly Detection', () => { + let anomalyDetector; + + beforeEach(() => { + anomalyDetector = new AnomalyDetection(); + }); + + test('should detect an anomaly in the data', () => { + const data = [1, 2, 3, 100, 5]; // 100 is an anomaly + const result = anomalyDetector.detect(data); + expect(result).toEqual([100]); + }); + + test('should return an empty array if no anomalies are found', () => { + const data = [1, 2, 3, 4, 5]; + const result = anomalyDetector.detect(data); + expect(result).toEqual([]); + }); + + test('should throw error if data is not provided', () => { + expect(() => anomalyDetector.detect()).toThrow('Data is required'); + }); +});