<commit_before>{StacktraceView, FrameView} = require '../lib/stacktrace-view'
{Stacktrace, Frame} = require '../lib/stacktrace'

frames = [
  new Frame('raw0', 'bottom.rb', 12, 'botfunc', 'Boom')
  new Frame('raw1', 'middle.rb', 42, 'midfunc')
  new Frame('raw2', 'top.rb', 37, 'topfunc')
]
trace = new Stacktrace(frames, 'Boom')

describe 'StacktraceView', ->
  [view] = []

  beforeEach ->
    view = new StacktraceView(trace)

  afterEach ->
    Stacktrace.clearRegistry()

  it 'registers an opener', ->
    opener = null
    mock =
      registerOpener: (callback) -> opener = callback
    StacktraceView.registerIn(mock)

    expect(opener).not.toBeNull()
    expect(opener '/some/other/path').toBeUndefined()

    trace.register()
    expect(opener(trace.getUrl()).trace).toBe(trace)

  it 'shows the error message', ->
    text = view.find('.error-message').text()
    expect(text).toEqual('Boom')

  it 'renders a subview for each frame'

describe 'FrameView', ->
  [view] = []

  beforeEach ->
    view = new FrameView(frames[1])

  it 'shows the filename'
  it 'shows the line number'
  it 'shows the function name'<commit_msg>Rendering a subview for each Frame.<commit_after>{StacktraceView, FrameView} = require '../lib/stacktrace-view'
{Stacktrace, Frame} = require '../lib/stacktrace'

frames = [
  new Frame('raw0', 'bottom.rb', 12, 'botfunc', 'Boom')
  new Frame('raw1', 'middle.rb', 42, 'midfunc')
  new Frame('raw2', 'top.rb', 37, 'topfunc')
]
trace = new Stacktrace(frames, 'Boom')

describe 'StacktraceView', ->
  [view] = []

  beforeEach ->
    view = new StacktraceView(trace)

  afterEach ->
    Stacktrace.clearRegistry()

  it 'registers an opener', ->
    opener = null
    mock =
      registerOpener: (callback) -> opener = callback
    StacktraceView.registerIn(mock)

    expect(opener).not.toBeNull()
    expect(opener '/some/other/path').toBeUndefined()

    trace.register()
    expect(opener(trace.getUrl()).trace).toBe(trace)

  it 'shows the error message', ->
    text = view.find('.error-message').text()
    expect(text).toEqual('Boom')

  it 'renders a subview for each frame', ->
    vs = view.find('.frame')
    expect(vs.length).toBe(3)

describe 'FrameView', ->
  [view] = []

  beforeEach ->
    view = new FrameView(frames[1])

  it 'shows the filename'
  it 'shows the line number'
  it 'shows the function name'
{'fraction_non_alphanumeric': 0.16476069462092333, 'fraction_numerical': 0.008894536213468869, 'mean_word_length': 3.586407766990291, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7567257', 'n_tokens_mistral': 814, 'n_tokens_neox': 778, 'n_words': 189}