Skip to content

Commit

Permalink
Create anomalyDetection.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 3, 2024
1 parent d4750d8 commit 462c082
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/anomalyDetection.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});

0 comments on commit 462c082

Please sign in to comment.