<commit_before>SupportedFiles = require '../lib/supported-files'

describe "SupportedFiles", ->

  ###
    Test isSupported(fileType)
  ###
  describe "when checking if an invalid file type is supported", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isSupported("randomtype")

    it "should return false", ->
      expect(result).toEqual(false)

  describe "when checking if an valid file type is supported", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isSupported("js")

    it "should return true", ->
      expect(result).toEqual(true)

  ###
    Test isTabBased(fileType)
  ###
  describe "when checking if an invalid file type is tab based", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isTabBased("invalid")

    it "should return false", ->
      expect(result).toEqual(false)

  describe "when checking if a non-tab based file type is tab based", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isTabBased("java")

    it "should return false", ->
      expect(result).toEqual(false)

  describe "when checking if a tab based file type is tab based", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isTabBased("py")

    it "should return true", ->
      expect(result).toEqual(true)

  ###
    Test getFunctionRegExpForFileType(fileType, functionName)
  ###
  describe "when getting the regular expression for an invalid file type", ->
    result = null

    it "should throw an error", ->
      expect(->
        SupportedFiles.getFunctionRegExpForFileType("invalid", "TEST")
      ).toThrow()

  describe "when getting the regular expression for a valid file type", ->
    result = null
    expectedResult = ///
      function \s+ TEST \s* \( | TEST \s* (=|:) \s* function \s* \(
    ///

    beforeEach ->
      result = SupportedFiles.getFunctionRegExpForFileType("js", "TEST")

    it "should return a regex with the new function name", ->
      expect(result).toEqual(expectedResult)<commit_msg>Updated test for new regex<commit_after>SupportedFiles = require '../lib/supported-files'

describe "SupportedFiles", ->

  ###
    Test isSupported(fileType)
  ###
  describe "when checking if an invalid file type is supported", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isSupported("randomtype")

    it "should return false", ->
      expect(result).toEqual(false)

  describe "when checking if an valid file type is supported", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isSupported("js")

    it "should return true", ->
      expect(result).toEqual(true)

  ###
    Test isTabBased(fileType)
  ###
  describe "when checking if an invalid file type is tab based", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isTabBased("invalid")

    it "should return false", ->
      expect(result).toEqual(false)

  describe "when checking if a non-tab based file type is tab based", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isTabBased("java")

    it "should return false", ->
      expect(result).toEqual(false)

  describe "when checking if a tab based file type is tab based", ->
    result = null

    beforeEach ->
      result = SupportedFiles.isTabBased("py")

    it "should return true", ->
      expect(result).toEqual(true)

  ###
    Test getFunctionRegExpForFileType(fileType, functionName)
  ###
  describe "when getting the regular expression for an invalid file type", ->
    result = null

    it "should throw an error", ->
      expect(->
        SupportedFiles.getFunctionRegExpForFileType("invalid", "TEST")
      ).toThrow()

  describe "when getting the regular expression for a valid file type", ->
    result = null
    expectedResult = ///
      function \s+ TEST \s* \(
        |
      TEST \s* (=|:) \s* function \s* \(
        |
      TEST \s* ([=:])? \s* \(? \s* \( ([\,\s\w]*)? \)? \s* =>
    ///

    beforeEach ->
      result = SupportedFiles.getFunctionRegExpForFileType("js", "TEST")

    it "should return a regex with the new function name", ->
      expect(result).toEqual(expectedResult)
{'fraction_non_alphanumeric': 0.12496995914443643, 'fraction_numerical': 0.0, 'mean_word_length': 2.773345421577516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 48, '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': '3930312', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1142, 'n_words': 363}