mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
onOptionChange/onSpecificOptionChange tests
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { OptionsService, DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||
import { IDisposable } from 'common/Types';
|
||||
|
||||
describe('OptionsService', () => {
|
||||
describe('constructor', () => {
|
||||
@@ -71,4 +72,44 @@ describe('OptionsService', () => {
|
||||
assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Wrong string literals should be reset to default');
|
||||
});
|
||||
});
|
||||
describe('onOptionChange', () => {
|
||||
let service: OptionsService;
|
||||
beforeEach(() => {
|
||||
service = new OptionsService({});
|
||||
});
|
||||
it('should fire on any option change', async () => {
|
||||
let disposable: IDisposable;
|
||||
await new Promise<void>(r => {
|
||||
disposable = service.onOptionChange(e => {
|
||||
assert.strictEqual(e, 'cursorWidth');
|
||||
r();
|
||||
});
|
||||
service.options.cursorWidth = 10;
|
||||
});
|
||||
disposable!.dispose();
|
||||
await new Promise<void>(r => {
|
||||
service.onOptionChange(e => {
|
||||
assert.strictEqual(e, 'scrollback');
|
||||
r();
|
||||
});
|
||||
service.options.scrollback = 20;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('onSpecificOptionChange', () => {
|
||||
let service: OptionsService;
|
||||
beforeEach(() => {
|
||||
service = new OptionsService({});
|
||||
});
|
||||
it('should fire only on a specific option change', async () => {
|
||||
await new Promise<void>(r => {
|
||||
service.onSpecificOptionChange('scrollback', e => {
|
||||
assert.strictEqual(e, 20);
|
||||
r();
|
||||
});
|
||||
service.options.cursorWidth = 10;
|
||||
service.options.scrollback = 20;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user