<commit_before>#= require jquery
#= require spec_helper
#= require modules
#= require module/graphic

describe "Graphic#constructor", ->
  describe 'with a visible drawer', ->
    before () ->
      @container = 'container404829'
      @metric_name = 'Pain'
      @module_id = '54405'
      $('body').html(JST['templates/metric_results']({container: @container, metric_name: @metric_name, module_id: @module_id}))

    it "should construct a graphic", ->
      graphic = new Module.Graphic(@container, @metric_name, @module_id)
<commit_msg>Graphic JS specs refactored so they do not rely on templates<commit_after>#= require jquery
#= require spec_helper
#= require modules
#= require module/graphic
#= require sinon

describe "Module.Graphic", ->
  describe "constructor", ->
    before ->
      @container = 'container404829'
      @metric_name = 'Pain'
      @module_id = '54405'

      @drawer = sinon.stub()
      sinon.stub(window, "$")
      $.withArgs("tr#"+@container).returns(@drawer)

    context 'when the drawer is hidden', ->
      before ->
        @drawer.is = sinon.stub().withArgs(':hidden').returns(true)

      it "should show the drawer and start to load a graphic", ->
        @drawer.slideDown = sinon.spy()

        Module.Graphic.prototype.load = sinon.spy()

        @graphic = new Module.Graphic(@container, @metric_name, @module_id)

        assert.isTrue(@drawer.slideDown.calledOnce)
        assert.isTrue(@graphic.load.calledOnce)

    context 'when the drawer is visible', ->
      before ->
        @drawer.is = sinon.stub().withArgs(':hidden').returns(false)

      it 'should hide the drawer', ->
        @drawer.slideUp = sinon.spy()

        @graphic = new Module.Graphic(@container, @metric_name, @module_id)

        assert.isTrue(@drawer.slideUp.calledOnce)
{'fraction_non_alphanumeric': 0.1407902058987201, 'fraction_numerical': 0.012242626599888704, 'mean_word_length': 3.2606635071090047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '5387418', 'n_tokens_mistral': 581, 'n_tokens_neox': 556, 'n_words': 128}