Sha256: eb50c59641c3ad7b8bff8b16eb1e4089748f043a1d1f6b24411e5266086f2dcf

Contents?: true

Size: 1.93 KB

Versions: 4

Compression:

Stored size: 1.93 KB

Contents

describe("ExceptionFormatter", function() {
  describe("#message", function() {
    it('formats Firefox exception messages', function() {
      var sampleFirefoxException = {
          fileName: 'foo.js',
          lineNumber: '1978',
          message: 'you got your foo in my bar',
          name: 'A Classic Mistake'
        },
        exceptionFormatter = new j$.ExceptionFormatter(),
        message = exceptionFormatter.message(sampleFirefoxException);

      expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
    });

    it('formats Webkit exception messages', function() {
      var sampleWebkitException = {
          sourceURL: 'foo.js',
          line: '1978',
          message: 'you got your foo in my bar',
          name: 'A Classic Mistake'
        },
        exceptionFormatter = new j$.ExceptionFormatter(),
        message = exceptionFormatter.message(sampleWebkitException);

      expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
    });

    it('formats V8 exception messages', function() {
      var sampleV8 = {
          message: 'you got your foo in my bar',
          name: 'A Classic Mistake'
        },
        exceptionFormatter = new j$.ExceptionFormatter(),
        message = exceptionFormatter.message(sampleV8);

      expect(message).toEqual('A Classic Mistake: you got your foo in my bar');

    });
  });

  describe("#stack", function() {
    it("formats stack traces from Webkit, Firefox, node.js or IE10+", function() {
      if (jasmine.getEnv().ieVersion < 10 || jasmine.getEnv().safariVersion < 6) { return; }

      var error;
      try { throw new Error("an error") } catch(e) { error = e; }

      expect(new j$.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
    });

    it("returns null if no Error provided", function() {
      expect(new j$.ExceptionFormatter().stack()).toBeNull();
    });
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jasmine-core-2.0.0 ./lib/jasmine-core/spec/core/ExceptionFormatterSpec.js
jasmine-core-2.0.0.rc5 ./lib/jasmine-core/spec/core/ExceptionFormatterSpec.js
jasmine-core-2.0.0.rc3 ./lib/jasmine-core/spec/core/ExceptionFormatterSpec.js
jasmine-core-2.0.0.rc2 ./lib/jasmine-core/spec/core/ExceptionFormatterSpec.js