<commit_before>TestConfig = require("./TestConfig")
Note = require('../coffee/Note').Note
should = require 'should'
fs = require 'fs'
util = require 'util'

describe 'Note', ->
  describe 'without resources', ->
    note_enml = fs.readFileSync TestConfig.fixtures['note']
    note = Note.parse note_enml
    describe '.parser()', ->
      it 'returns a note object.', ->
        note.should.be.an.instanceof(Note)
    
    describe '#filename(extention)', ->
      it 'escapes title string.', ->
        note.filename('.md').should.equal 'a single note fixture test  1.md'
        note.filename('.txt').should.equal 'a single note fixture test  1.txt'
    
    describe '#title', ->
      it 'is a title string.', ->
        note.title.should.equal 'a single note fixture/test: 1'
    
    describe '#created', ->
      it '#created is a Date object.', ->
        date = new Date 2013, 10, 2, 10, 7-TestConfig.TZOffsetMinutes, 9 # 20131102T100709Z
        note.created.should.be.an.instanceof Date
        note.created.should.eql date
    
    describe '#updated', ->
      it '#updated is a Date object.', ->
        date = new Date 2013, 10, 2, 10, 7-TestConfig.TZOffsetMinutes, 13  # 20131102T100713Z
        note.updated.should.be.an.instanceof Date
        note.updated.should.eql date
    
    describe '#tags', ->
      it 'is an array of string.', ->
        note.tags.should.be.an.instanceof Array
        note.tags.length.should.equal 2
        note.tags[0].should.equal 'markdown'
        note.tags[1].should.equal 'evernote'
    
    describe '#content', ->
      it 'is a Markdown string.', ->
        note.content.should.equal 'fixture content\n\n'

  describe 'with image resources', () ->
    note_enml = fs.readFileSync TestConfig.fixtures['image']
    note = Note.parse note_enml
    hash = '095619d89dbbd6a0c5704d57e444f708'
    content_expected = ' The first line.\n\n' +
      '![png image][0]\n\n' +
      'The end line.\n\n\n\n' +
      '[0]: resources/' + hash + '.png'
    describe '@attachments', ->
      it 'are loaded.', () ->
        note.content.should.equal content_expected
        note.attachmentsLength.should.equal 1
        note.attachments[hash].data.length.should.equal 7551<commit_msg>refine test spec<commit_after>TestConfig = require("./TestConfig")
Note = require('../coffee/Note').Note
should = require 'should'
fs = require 'fs'
util = require 'util'

describe 'Note', ->
  describe 'without resources', ->
    note_enml = fs.readFileSync TestConfig.fixtures['note']
    note = Note.parse note_enml
    describe '.parse()', ->
      it 'returns a note object.', ->
        note.should.be.an.instanceof(Note)
    
    describe '#filename(extention)', ->
      it 'escapes title string.', ->
        note.filename('.md').should.equal 'a single note fixture test  1.md'
        note.filename('.txt').should.equal 'a single note fixture test  1.txt'
    
    describe '@title', ->
      it 'is a title string.', ->
        note.title.should.equal 'a single note fixture/test: 1'
    
    describe '@created', ->
      it 'is a Date object.', ->
        date = new Date 2013, 10, 2, 10, 7-TestConfig.TZOffsetMinutes, 9 # 20131102T100709Z
        note.created.should.be.an.instanceof Date
        note.created.should.eql date
    
    describe '@updated', ->
      it 'is a Date object.', ->
        date = new Date 2013, 10, 2, 10, 7-TestConfig.TZOffsetMinutes, 13  # 20131102T100713Z
        note.updated.should.be.an.instanceof Date
        note.updated.should.eql date
    
    describe '@tags', ->
      it 'is an array of string.', ->
        note.tags.should.be.an.instanceof Array
        note.tags.length.should.equal 2
        note.tags[0].should.equal 'markdown'
        note.tags[1].should.equal 'evernote'
    
    describe '@content', ->
      it 'is a Markdown string.', ->
        note.content.should.equal 'fixture content\n\n'

  describe 'with an image attachment', () ->
    note_enml = fs.readFileSync TestConfig.fixtures['image']
    note = Note.parse note_enml
    hash = '095619d89dbbd6a0c5704d57e444f708'
    content_expected = ' The first line.\n\n' +
      '![png image][0]\n\n' +
      'The end line.\n\n\n\n' +
      '[0]: resources/' + hash + '.png'
    describe '@attachments', ->
      it 'are loaded.', () ->
        note.content.should.equal content_expected
        note.attachmentsLength.should.equal 1
        note.attachments[hash].data.length.should.equal 7551
{'fraction_non_alphanumeric': 0.14330779630464174, 'fraction_numerical': 0.03875619648490311, 'mean_word_length': 2.46796875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '4763251', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1386, 'n_words': 342}