Skip to content

Commit

Permalink
lot of fixes to echo newline + unit tests #511
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 28, 2019
1 parent 622bd36 commit 72e63e4
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* new events `onBeforeLogin`, `onAfterLogin`, `onBeforeEcho` and `onAfterEcho`
* inherit of style in nesting formatter (with flag `__inherit__ = true` on `nested_formatting`) [#513](https://github.com/jcubic/jquery.terminal/issues/513)
* image formatting (less with images [#515](https://github.com/jcubic/jquery.terminal/issues/515))
* new `echo_command` API method (for echo_newline default action)
### Bugfix
* add missing `onAfterCommand` and `onBeforeCommand` to d.ts file
* fix Emoji [#514](https://github.com/jcubic/jquery.terminal/issues/514)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ http://terminal.jcubic.pl

[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=devel&0371d26ee8fcf1c619c21c657388839150d3ae9d)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&a56f3aa50d88c363e44d21c063c02b3e)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=devel&622bd362f7f7121ec4bed2eaf5b7b5e8fad8799a)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&23020dde3e92637f6a5b31ad9c61b28c)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![package quality](http://npm.packagequality.com/shield/jquery.terminal.svg)](http://packagequality.com/#?package=jquery.terminal)
[![](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery.terminal)
Expand Down
51 changes: 49 additions & 2 deletions __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ global.wcwidth = require('wcwidth');
require('../js/jquery.terminal-src')(global.$);
require('../js/unix_formatting')(global.$);
require('../js/pipe')(global.$);
require('../js/echo_newline')(global.$);
//require('../js/autocomplete_menu')(global.$);

jest.setTimeout(10000);

Expand Down Expand Up @@ -2222,6 +2224,49 @@ describe('Terminal utils', function() {
});
});
});
describe('extensions', function() {
describe('echo_newline', function() {
var term = $('<div/>').terminal();
beforeEach(function() {
term.clear();
});
it('should display single line', async function() {
var prompt = '>>> ';
term.set_prompt(prompt);
term.echo('.', {newline: false});
await delay(10);
term.echo('.', {newline: false});
await delay(10);
term.echo('.', {newline: false});
await delay(10);
term.echo('.');
expect(term.get_output()).toEqual('....');
expect(term.get_prompt()).toEqual(prompt);
});
it('should echo prompt and command', function() {
var prompt = '>>> ';
var command = 'hello';
term.set_prompt(prompt);
term.echo('.', {newline: false});
term.echo('.', {newline: false});
term.echo('.', {newline: false});
term.exec('hello');
expect(term.get_output()).toEqual('...' + prompt + command);
expect(term.get_prompt()).toEqual(prompt);
});
it('should echo prompt on enter', function() {
var prompt = '>>> ';
var command = 'hello';
term.set_prompt(prompt);
term.echo('.', {newline: false});
term.echo('.', {newline: false});
term.echo('.', {newline: false});
enter(term, command);
expect(term.get_output()).toEqual('...' + prompt + command);
expect(term.get_prompt()).toEqual(prompt);
});
});
});
describe('sub plugins', function() {
describe('text_length', function() {
it('should return length of the text in div', function() {
Expand Down Expand Up @@ -4567,8 +4612,10 @@ describe('Terminal plugin', function() {
term.destroy().remove();
for (var key in settings) {
// name is selector if not defined
if (settings.hasOwnProperty(key) && key !== 'name') {
expect($.terminal.defaults[key]).toEqual(settings[key]);
if (settings.hasOwnProperty(key) &&
!['name', 'exit', 'keymap', 'echoCommand'].includes(key)) {
// without name and exit + exeptions in newline
expect([key, $.terminal.defaults[key]]).toEqual([key, settings[key]]);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion css/emoji.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/jquery.terminal-2.7.1.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Copyright (c) 2011-2019 Jakub Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
* Date: Thu, 22 Aug 2019 19:36:50 +0000
* Date: Wed, 28 Aug 2019 19:08:47 +0000
*/
.terminal .terminal-output .format, .cmd .format,
.cmd-prompt, .cmd-prompt div {
Expand Down
Loading

0 comments on commit 72e63e4

Please sign in to comment.