Sha256: 70c554e1f809350b032d5f596fe4d63ebbb6d5e64f2fefa27bc9164cdbc5edba

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

describe("AnsiStream", function() {
  var expectClass, stream;
  stream = null;
  beforeEach(function() {
    return stream = new AnsiStream();
  });
  expectClass = function(span, color) {
    return expect(span).toMatch(new RegExp("class='[^']*" + color + ".*'"));
  };
  it('returns uncolorized spans if there are no escape codes', function() {
    return expect(stream.process("toto")[0]).toBe("toto");
  });
  it('returns colorized spans if there is an foreground color code', function() {
    return expectClass(stream.process('\u001B[31mtoto')[0], 'ansi-foreground-red');
  });
  it('returns colorized spans if there is an background color code', function() {
    return expectClass(stream.process("\u001B[41mtoto")[0], 'ansi-background-red');
  });
  it('keeps modifying the style', function() {
    var span;
    stream.process("\u001B[41mtoto")[0];
    span = stream.process('\u001B[31mtoto')[0];
    expectClass(span, 'ansi-background-red');
    return expectClass(span, 'ansi-foreground-red');
  });
  it('resets the style when encountering a marker', function() {
    var spans;
    spans = stream.process("\u001B[41;31mtoto\u001B[0mtiti");
    expectClass(spans[0], 'ansi-background-red');
    return expectClass(spans[1], 'ansi-background-default');
  });
  it('makes the text bright', function() {
    return expectClass(stream.process("\u001B[1mtoto")[0], 'ansi-bright');
  });
  return it('handles underline', function() {
    var spans;
    spans = stream.process("\u001B[4mtoto\u001B[24mtiti");
    expectClass(spans[0], 'ansi-underline');
    return expect(spans[1].indexOf('ansi-underline')).toBe(-1);
  });
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ansi_stream-0.0.6 spec/javascripts/ansi_stream_spec.js
ansi_stream-0.0.5 spec/javascripts/ansi_stream_spec.js
ansi_stream-0.0.4 spec/javascripts/ansi_stream_spec.js
ansi_stream-0.0.3 spec/javascripts/ansi_stream_spec.js
ansi_stream-0.0.2 spec/javascripts/ansi_stream_spec.js
ansi_stream-0.0.1 spec/javascripts/ansi_stream_spec.js