<commit_before>jsdom = require('jsdom').jsdom

GomlLoader = require '../../src/Goml/GomlLoader'

describe 'GomlLoader', ->
  describe 'loadScriptTag', ->
    global.document = jsdom '<html><body><script></script></body></html>'
    global.window = global.document.parentWindow
    $ = global.jQuery = require('jquery')(global.window)
    instance = null

    before ->

    beforeEach ->
      instance = new GomlLoader()

    it 'should return goml source string when jQuery object which has src attribute is given', ->
      obj = $('<script type=\'text/goml\'>{{goml}}</script>')
      mock = sinon.mock(instance)
      mock.expects('scriptLoaded').withArgs('{{goml}}')
      instance.loadScriptTag(obj)
      assert(mock.verify() == true)
<commit_msg>add test<commit_after>jsdom = require('jsdom').jsdom

global.document = jsdom '<html><body></body></html>'
global.window = document.parentWindow

$ = require 'jquery'

GomlLoader = require '../../src/Goml/GomlLoader'

describe 'GomlLoader', ->
  describe 'loadScriptTag', ->
    instance = null

    beforeEach ->
      instance = new GomlLoader()

    it 'should return goml source string when jQuery object which does not have src attribute is given', ->
      obj = $('<script type=\'text/goml\'>{{goml}}</script>')
      mock = sinon.mock(instance)
      mock.expects('scriptLoaded').withArgs('{{goml}}')
      instance.loadScriptTag(obj)
      assert(mock.verify() == true)

  describe 'scriptLoaded', ->
    instance = null

    beforeEach ->
      instance = new GomlLoader()

    it 'should throw error when goml source is empty', ->
      source = ''
      spy = sinon.spy(instance, 'scriptLoaded')
      try spy(source)
      assert(spy.threw() == true)

{'fraction_non_alphanumeric': 0.15823152995927864, 'fraction_numerical': 0.0, 'mean_word_length': 3.28927680798005, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, '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': '7542853', 'n_tokens_mistral': 535, 'n_tokens_neox': 523, 'n_words': 121}