75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import { expect, tap } from '@push.rocks/tapbundle';
|
|
import { SmartlogSourceOra } from '../ts_source_ora/index.js';
|
|
|
|
let testSourceOra: SmartlogSourceOra;
|
|
|
|
tap.test('should create a SmartlogSourceOra instance', async () => {
|
|
testSourceOra = new SmartlogSourceOra();
|
|
expect(testSourceOra).toBeTruthy();
|
|
expect(testSourceOra.started).toBeFalse();
|
|
});
|
|
|
|
tap.test('should set text and start spinner', async () => {
|
|
const testText = 'Testing ora spinner';
|
|
testSourceOra.text(testText);
|
|
|
|
expect(testSourceOra.started).toBeTrue();
|
|
expect(testSourceOra.oraInstance.text).toEqual(testText);
|
|
});
|
|
|
|
tap.test('should update text', async () => {
|
|
const newText = 'Updated text';
|
|
testSourceOra.text(newText);
|
|
|
|
expect(testSourceOra.oraInstance.text).toEqual(newText);
|
|
expect(testSourceOra.started).toBeTrue();
|
|
});
|
|
|
|
tap.test('should stop spinner', async () => {
|
|
testSourceOra.stop();
|
|
// We can't easily test the visual state, but we can verify it doesn't throw errors
|
|
});
|
|
|
|
tap.test('should finish with success', async () => {
|
|
testSourceOra = new SmartlogSourceOra();
|
|
testSourceOra.text('Starting again');
|
|
|
|
const successText = 'Operation successful';
|
|
testSourceOra.finishSuccess(successText);
|
|
|
|
expect(testSourceOra.started).toBeFalse();
|
|
});
|
|
|
|
tap.test('should finish with failure', async () => {
|
|
testSourceOra = new SmartlogSourceOra();
|
|
testSourceOra.text('Starting again');
|
|
|
|
const failText = 'Operation failed';
|
|
testSourceOra.finishFail(failText);
|
|
|
|
expect(testSourceOra.started).toBeFalse();
|
|
});
|
|
|
|
tap.test('should handle success and next', async () => {
|
|
testSourceOra = new SmartlogSourceOra();
|
|
testSourceOra.text('Starting again');
|
|
|
|
const nextText = 'Next operation';
|
|
testSourceOra.successAndNext(nextText);
|
|
|
|
expect(testSourceOra.started).toBeTrue();
|
|
expect(testSourceOra.oraInstance.text).toEqual(nextText);
|
|
});
|
|
|
|
tap.test('should handle fail and next', async () => {
|
|
testSourceOra = new SmartlogSourceOra();
|
|
testSourceOra.text('Starting again');
|
|
|
|
const nextText = 'Next operation after failure';
|
|
testSourceOra.failAndNext(nextText);
|
|
|
|
expect(testSourceOra.started).toBeTrue();
|
|
expect(testSourceOra.oraInstance.text).toEqual(nextText);
|
|
});
|
|
|
|
export default tap.start(); |