<commit_before>require '../testHelper'
CourseUtils = require '../../app/assets/javascripts/utils/course_utils'

describe 'CourseUtils.generateTempId', ->
  it 'creates a slug from term, title and school', ->
    course =
      term: 'Fall 2015'
      school: 'University of Wikipedia'
      title: 'Introduction to Editing'
    slug = CourseUtils.generateTempId(course)
    expect(slug).to.eq 'University_of_Wikipedia/Introduction_to_Editing_(Fall_2015)'

  it 'trims unnecessary whitespace', ->
    course =
      term: ' Fall 2015'
      school: '   University of Wikipedia '
      title: ' Introduction to Editing     '
    slug = CourseUtils.generateTempId(course)
    expect(slug).to.eq 'University_of_Wikipedia/Introduction_to_Editing_(Fall_2015)'

describe 'CourseUtils.cleanupCourseSlugComponents', ->
  it 'trims whitespace from the slug-related fields of a course object', ->
    course =
      term: ' Fall 2015'
      school: '   University of Wikipedia '
      title: ' Introduction to Editing     '
    updatedCourse = CourseUtils.cleanupCourseSlugComponents(course)
    expect(course.term).to.eq 'Fall 2015'
    expect(course.school).to.eq 'University of Wikipedia'
    expect(course.title).to.eq 'Introduction to Editing'<commit_msg>Add test for CourseUtils.i18n<commit_after>require '../testHelper'
require '../../public/assets/javascripts/i18n/en'
CourseUtils = require '../../app/assets/javascripts/utils/course_utils'

describe 'CourseUtils.generateTempId', ->
  it 'creates a slug from term, title and school', ->
    course =
      term: 'Fall 2015'
      school: 'University of Wikipedia'
      title: 'Introduction to Editing'
    slug = CourseUtils.generateTempId(course)
    expect(slug).to.eq 'University_of_Wikipedia/Introduction_to_Editing_(Fall_2015)'

  it 'trims unnecessary whitespace', ->
    course =
      term: ' Fall 2015'
      school: '   University of Wikipedia '
      title: ' Introduction to Editing     '
    slug = CourseUtils.generateTempId(course)
    expect(slug).to.eq 'University_of_Wikipedia/Introduction_to_Editing_(Fall_2015)'

describe 'CourseUtils.cleanupCourseSlugComponents', ->
  it 'trims whitespace from the slug-related fields of a course object', ->
    course =
      term: ' Fall 2015'
      school: '   University of Wikipedia '
      title: ' Introduction to Editing     '
    updatedCourse = CourseUtils.cleanupCourseSlugComponents(course)
    expect(course.term).to.eq 'Fall 2015'
    expect(course.school).to.eq 'University of Wikipedia'
    expect(course.title).to.eq 'Introduction to Editing'

describe 'CourseUtils.i18n', ->
  it 'outputs an interface message based on a message key and prefix', ->
    message = CourseUtils.i18n('students', 'courses_generic')
    expect(message).to.eq 'Editors'
  it 'defaults to the "courses" prefix if prefix is null', ->
    message = CourseUtils.i18n('students', null)
    expect(message).to.eq 'Students'
  it 'takes an optional fallback prefix for if prefix is null', ->
    message = CourseUtils.i18n('class', null, 'revisions')
    expect(message).to.eq 'Class'
{'fraction_non_alphanumeric': 0.11114722131946701, 'fraction_numerical': 0.019499512512187196, 'mean_word_length': 3.6778115501519757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2738443', 'n_tokens_mistral': 970, 'n_tokens_neox': 888, 'n_words': 235}