mirror of
https://github.com/wassname/nvatom.git
synced 2026-08-12 12:10:23 +08:00
Fix a bug that utility.isNote does not handle symlinks properly
This commit is contained in:
@@ -3,6 +3,8 @@ path = require 'path'
|
||||
temp = require 'temp'
|
||||
Interlink = require '../lib/interlink'
|
||||
|
||||
temp.track()
|
||||
|
||||
describe 'Interlink', ->
|
||||
defaultDirectory = atom.config.get('nvatom.directory')
|
||||
noteDirectory = null
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
path = require 'path'
|
||||
temp = require 'temp'
|
||||
|
||||
temp.track()
|
||||
|
||||
describe "nvAtom", ->
|
||||
defaultDirectory = atom.config.get('nvatom.directory')
|
||||
activationPromise = null
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
fs = require 'fs-plus'
|
||||
path = require 'path'
|
||||
temp = require 'temp'
|
||||
Utility = require '../lib/utility'
|
||||
|
||||
temp.track()
|
||||
|
||||
describe "utility", ->
|
||||
defaultNoteDirectory = atom.config.get('nvatom.directory')
|
||||
defaultNoteExtensions = atom.config.get('nvatom.extensions')
|
||||
@@ -23,3 +28,27 @@ describe "utility", ->
|
||||
expect(Utility.getPrimaryNoteExtension()).toBe('.markdown')
|
||||
atom.config.set('nvatom.extensions', [])
|
||||
expect(Utility.getPrimaryNoteExtension()).toBe('.md')
|
||||
|
||||
describe 'isNote handles symlinks correctly', ->
|
||||
atom.config.set('nvatom.extensions', ['.md', '.markdown'])
|
||||
|
||||
tempDirectoryPath = path.join(temp.mkdirSync())
|
||||
noteDirectoryPath = path.join(temp.mkdirSync())
|
||||
noteDirectoryPathSymlink = path.join(tempDirectoryPath, 'note book')
|
||||
notePath = path.join(noteDirectoryPath, 'note.md')
|
||||
notePathSymlink = path.join(noteDirectoryPathSymlink, 'note symlink.md')
|
||||
|
||||
fs.writeFileSync(notePath, 'dummy')
|
||||
fs.symlinkSync(noteDirectoryPath, noteDirectoryPathSymlink)
|
||||
fs.symlinkSync(notePath, notePathSymlink)
|
||||
|
||||
expect(fs.existsSync(notePath)).toBe(true)
|
||||
expect(fs.existsSync(fs.normalize(notePath))).toBe(true)
|
||||
|
||||
atom.config.set('nvatom.directory', noteDirectoryPath)
|
||||
expect(Utility.isNote(notePath)).toBe(true)
|
||||
expect(Utility.isNote(notePathSymlink)).toBe(true)
|
||||
|
||||
atom.config.set('nvatom.directory', noteDirectoryPathSymlink)
|
||||
expect(Utility.isNote(notePath)).toBe(true)
|
||||
expect(Utility.isNote(notePathSymlink)).toBe(true)
|
||||
|
||||
Reference in New Issue
Block a user