Skip to content

Commit

Permalink
Create sentimentAnalysis.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent 540d3f6 commit d8c6716
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/sentimentAnalysis.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// sentimentAnalysis.test.js

const SentimentAnalysis = require('./sentimentAnalysis'); // Assuming you have a SentimentAnalysis module

describe('Sentiment Analysis Functionalities', () => {
let sentimentAnalysis;

beforeEach(() => {
sentimentAnalysis = new SentimentAnalysis();
});

test('should return positive sentiment for positive text', () => {
const result = sentimentAnalysis.analyze('I love programming!');
expect(result).toBeGreaterThan(0);
});

test('should return negative sentiment for negative text', () => {
const result = sentimentAnalysis.analyze('I hate bugs!');
expect(result).toBeLessThan(0);
});

test('should return neutral sentiment for neutral text', () => {
const result = sentimentAnalysis.analyze('This is a sentence.');
expect(result).toBe(0);
});

test('should handle empty text gracefully', () => {
const result = sentimentAnalysis.analyze('');
expect(result).toBe(0); // Assuming neutral sentiment for empty text
});
});

0 comments on commit d8c6716

Please sign in to comment.