mirror of
https://github.com/wassname/nvatom.git
synced 2026-07-03 17:10:17 +08:00
2b442b79e7
Refactor so that the note/directory parsing is done in separate classes.
37 lines
1.1 KiB
CoffeeScript
37 lines
1.1 KiB
CoffeeScript
path = require 'path'
|
|
fs = require 'fs-plus'
|
|
temp = require 'temp'
|
|
pathWatcher = require 'pathwatcher'
|
|
Note = require '../lib/note'
|
|
|
|
describe 'Note', ->
|
|
defaultDirectory = atom.config.get('notational-velocity.directory')
|
|
tempDirectory = temp.mkdirSync('node-pathwatcher-directory')
|
|
tempFilePath = path.join(tempDirectory, 'Temp.md')
|
|
|
|
beforeEach ->
|
|
atom.config.set('notational-velocity.directory', tempDirectory)
|
|
fs.writeFileSync(tempFilePath, 'old')
|
|
|
|
afterEach ->
|
|
fs.unlinkSync(tempFilePath)
|
|
atom.config.set('notational-velocity.directory', defaultDirectory)
|
|
|
|
it 'creates a note', ->
|
|
note = new Note(tempFilePath, null, null)
|
|
expect(note.getTitle()).toBe 'Temp'
|
|
expect(note.getText()).toBe 'old'
|
|
expect(note.getFilePath()).toBe tempFilePath
|
|
note.destroy()
|
|
|
|
it 'modifies a note', ->
|
|
note = new Note(tempFilePath, null, null)
|
|
expect(note.getText()).toBe 'old'
|
|
|
|
fs.writeFileSync(tempFilePath, 'new')
|
|
oldModified = note.getModified()
|
|
waitsFor -> oldModified != note.getModified()
|
|
runs ->
|
|
expect(note.getText()).toBe 'new'
|
|
note.destroy()
|