<commit_before>/* Test flow
1. Use a local html page to see if parser could extract correct message from the page.
 */
const cur = require('../../app/thulib/curriculum')
const readFile = require('fs-readfile-promise')
const cheerio = require('cheerio')

describe('1. test parser', () => {
  it('1.1 curriculum info should be properly extracted form the right test page', async () =>{
    const data = await readFile(`${__dirname}\\test-right.html`, 'utf8')
    const $ = cheerio.load(data, { decodeEntities: false })
    const classes = await cur.parseFirstLevelCurriculum($)
    classes.should.be.Array().and.should.not.be.empty()
    
    const lesson = classes[0]
    const properties = ['courseid', 'coursename', 'time', 'teacher', 'classroom', 'week']
    lesson.should.have.properties(properties)

    const time = lesson.time
    time.should.be.Array().and.have.length(2)
    time[0].should.be.Number().and.within(1, 7)
    time[1].should.be.Number().and.within(1, 6)

    const week = lesson.week
    week.should.be.Array().and.have.length(16)
    week.forEach((ele) => {
      ele.should.be.Number().and.within(0, 1)
    })
  })
  
  //FIXME: How to test an exception threwed by async function properly
  /*<commit_msg>modify the fixme comment<commit_after>/* Test flow
1. Use a local html page to see if parser could extract correct message from the page.
 */
const cur = require('../../app/thulib/curriculum')
const readFile = require('fs-readfile-promise')
const cheerio = require('cheerio')

describe('1. test parser', () => {
  it('1.1 curriculum info should be properly extracted form the right test page', async () =>{
    const data = await readFile(`${__dirname}\\test-right.html`, 'utf8')
    const $ = cheerio.load(data, { decodeEntities: false })
    const classes = await cur.parseFirstLevelCurriculum($)
    classes.should.be.Array().and.should.not.be.empty()
    
    const lesson = classes[0]
    const properties = ['courseid', 'coursename', 'time', 'teacher', 'classroom', 'week']
    lesson.should.have.properties(properties)

    const time = lesson.time
    time.should.be.Array().and.have.length(2)
    time[0].should.be.Number().and.within(1, 7)
    time[1].should.be.Number().and.within(1, 6)

    const week = lesson.week
    week.should.be.Array().and.have.length(16)
    week.forEach((ele) => {
      ele.should.be.Number().and.within(0, 1)
    })
  })
  
  //FIXME: How to test an exception thrown by async function properly
  /*
{'fraction_non_alphanumeric': 0.1597729115977291, 'fraction_numerical': 0.013787510137875101, 'mean_word_length': 3.5018248175182483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5413981', 'n_tokens_mistral': 795, 'n_tokens_neox': 782, 'n_words': 197}