diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-05 19:37:52 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-05 19:37:52 +0900 |
commit | 2cbdc483b7ecdee0627daaf934e6010e77d68a77 (patch) | |
tree | 6f8b8667f835bfb7e778cc571d8869cb5903a08a /test | |
parent | 8cabd68b927fe7022efa11dee082aafe8c2d4f30 (diff) | |
parent | c507f7febf0d8827dafcc6fd543678af447c056c (diff) |
Merge branch 'buffer-completion'
Diffstat (limited to 'test')
-rw-r--r-- | test/console/completion.test.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/console/completion.test.js b/test/console/completion.test.js new file mode 100644 index 0000000..a789c15 --- /dev/null +++ b/test/console/completion.test.js @@ -0,0 +1,48 @@ +import { expect } from "chai"; +import Completion from '../../src/console/completion'; + +describe('Completion class', () => { + describe('#constructor', () => { + it('creates new object by iterable items', () => { + new Completion([1,2,3,4,5]); + new Completion([]); + new Completion('hello'); + new Completion(''); + }); + + it('creates new object by iterable items', () => { + expect(() => new Completion({ key: 'value' })).to.throw(TypeError); + expect(() => new Completion(12345)).to.throw(TypeError); + }); + }); + + describe('#next', () => { + it('complete next items', () => { + let completion = new Completion([3, 4, 5]); + expect(completion.next()).to.equal(3); + expect(completion.next()).to.equal(4); + expect(completion.next()).to.equal(5); + expect(completion.next()).to.equal(3); + }); + + it('returns null when empty completions', () => { + let completion = new Completion([]); + expect(completion.next()).to.be.null; + }); + }); + + describe('#prev', () => { + it('complete prev items', () => { + let completion = new Completion([3, 4, 5]); + expect(completion.prev()).to.equal(5); + expect(completion.prev()).to.equal(4); + expect(completion.prev()).to.equal(3); + expect(completion.prev()).to.equal(5); + }); + + it('returns null when empty completions', () => { + let completion = new Completion([]); + expect(completion.prev()).to.be.null; + }); + }); +}); |