-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement tests for
Buffer
and BufferSet
- Loading branch information
Showing
3 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @license MIT | ||
*/ | ||
import { assert } from 'chai'; | ||
import { ITerminal } from './Interfaces'; | ||
import { Buffer } from './Buffer'; | ||
import { CircularList } from './utils/CircularList'; | ||
|
||
describe('Buffer', () => { | ||
let terminal: ITerminal; | ||
let buffer: Buffer; | ||
|
||
beforeEach(() => { | ||
terminal = <any>{ | ||
cols: 80, | ||
rows: 24, | ||
scrollback: 1000 | ||
}; | ||
buffer = new Buffer(terminal); | ||
}); | ||
|
||
describe('constructor', () => { | ||
it('should create a CircularList with max length equal to scrollback, for its lines', () => { | ||
assert.instanceOf(buffer.lines, CircularList); | ||
assert.equal(buffer.lines.maxLength, terminal.scrollback); | ||
}); | ||
it('should set the Buffer\'s scrollBottom value equal to the terminal\'s rows -1', () => { | ||
assert.equal(buffer.scrollBottom, terminal.rows - 1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @license MIT | ||
*/ | ||
import { assert } from 'chai'; | ||
import { ITerminal } from './Interfaces'; | ||
import { BufferSet } from './BufferSet'; | ||
import { Buffer } from './Buffer'; | ||
|
||
describe('BufferSet', () => { | ||
let terminal: ITerminal; | ||
let bufferSet: BufferSet; | ||
|
||
beforeEach(() => { | ||
terminal = <any>{ | ||
cols: 80, | ||
rows: 24, | ||
scrollback: 1000 | ||
}; | ||
bufferSet = new BufferSet(terminal); | ||
}); | ||
|
||
describe('constructor', () => { | ||
it('should create two different buffers: alt and normal', () => { | ||
assert.instanceOf(bufferSet.normal, Buffer); | ||
assert.instanceOf(bufferSet.alt, Buffer); | ||
assert.notEqual(bufferSet.normal, bufferSet.alt); | ||
}); | ||
}); | ||
|
||
describe('activateNormalBuffer', () => { | ||
beforeEach(() => { | ||
bufferSet.activateNormalBuffer(); | ||
}); | ||
|
||
it('should set the normal buffer as the currently active buffer', () => { | ||
assert.equal(bufferSet.active, bufferSet.normal); | ||
}); | ||
}); | ||
|
||
describe('activateAltBuffer', () => { | ||
beforeEach(() => { | ||
bufferSet.activateAltBuffer(); | ||
}); | ||
|
||
it('should set the alt buffer as the currently active buffer', () => { | ||
assert.equal(bufferSet.active, bufferSet.alt); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters