Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/happymandarin/node_modules/table/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/happymandarin/node_modules/table/test/alignString.js
/* eslint-disable max-nested-callbacks */

import {
    expect
} from 'chai';
import chalk from 'chalk';
import alignString from './../src/alignString';

describe('alignString', () => {
  context('subject parameter value is not a string', () => {
    it('throws an error', () => {
      expect(() => {
        alignString();
      }).to.throw(Error, 'Subject parameter value must be a string.');
    });
  });
  context('container width parameter value is not a string', () => {
    it('throws an error', () => {
      expect(() => {
        alignString('');
      }).to.throw(Error, 'Container width parameter value must be a number.');
    });
  });
  context('subject parameter value width is greater than the container width', () => {
    it('throws an error', () => {
      expect(() => {
        alignString('aa', 1, 'left');
      }).to.throw(Error, 'Subject parameter value width cannot be greater than the container width.');
    });
  });
  context('container alignment parameter value is not a string', () => {
    it('throws an error', () => {
      expect(() => {
        alignString('', 1);
      }).to.throw(Error, 'Alignment parameter value must be a string.');
    });
  });
  context('container alignment parameter value is not a known alignment parameter value', () => {
    it('throws an error', () => {
      expect(() => {
        alignString('', 1, 'foo');
      }).to.throw(Error, 'Alignment parameter value must be a known alignment parameter value (left, right, center).');
    });
  });
  context('subject parameter value', () => {
    context('0 width', () => {
      it('produces a string consisting of container width number of whitespace characters', () => {
        expect(alignString('', 5, 'left')).to.equal('     ', 'left');
        expect(alignString('', 5, 'center')).to.equal('     ', 'center');
        expect(alignString('', 5, 'right')).to.equal('     ', 'right');
      });
    });
    context('plain text', () => {
      context('alignment', () => {
        context('left', () => {
          it('pads the string on the right side using a whitespace character', () => {
            expect(alignString('aa', 6, 'left')).to.equal('aa    ');
          });
        });
        context('right', () => {
          it('pads the string on the left side using a whitespace character', () => {
            expect(alignString('aa', 6, 'right')).to.equal('    aa');
          });
        });
        context('center', () => {
          it('pads the string on both sides using a whitespace character', () => {
            expect(alignString('aa', 6, 'center')).to.equal('  aa  ');
          });
          context('uneven number of available with', () => {
            it('floors the available width; adds extra space to the end of the string', () => {
              expect(alignString('aa', 7, 'center')).to.equal('  aa   ');
            });
          });
        });
      });
    });
    context('text containing ANSI escape codes', () => {
      context('alignment', () => {
        context('left', () => {
          it('pads the string on the right side using a whitespace character', () => {
            expect(alignString(chalk.red('aa'), 6, 'left')).to.equal(chalk.red('aa') + '    ');
          });
        });
        context('right', () => {
          it('pads the string on the left side using a whitespace character', () => {
            expect(alignString(chalk.red('aa'), 6, 'right')).to.equal('    ' + chalk.red('aa'));
          });
        });
        context('center', () => {
          it('pads the string on both sides using a whitespace character', () => {
            expect(alignString(chalk.red('aa'), 6, 'center')).to.equal('  ' + chalk.red('aa') + '  ');
          });
          context('uneven number of available with', () => {
            it('floors the available width; adds extra space to the end of the string', () => {
              expect(alignString(chalk.red('aa'), 7, 'center')).to.equal('  ' + chalk.red('aa') + '   ');
            });
          });
        });
      });
    });
  });
});

Youez - 2016 - github.com/yon3zu
LinuXploit