From 9863386644bbae4c89399f36eedb056c66f64d50 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 5 Nov 2013 16:36:51 -0800 Subject: [PATCH] Update Directory specs for platform specific issues --- spec/directory-spec.coffee | 70 +++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/spec/directory-spec.coffee b/spec/directory-spec.coffee index 56b40fe05..c611a7b05 100644 --- a/spec/directory-spec.coffee +++ b/spec/directory-spec.coffee @@ -66,32 +66,45 @@ describe "Directory", -> waits 20 runs -> expect(changeHandler.callCount).toBe 0 - it "includes symlink information about entries", -> - entries = directory.getEntries() - for entry in entries - name = entry.getBaseName() - if name is 'symlink-to-dir' or name is 'symlink-to-file' - expect(entry.symlink).toBeTruthy() - else - expect(entry.symlink).toBeFalsy() + describe "on #darwin or #linux", -> + it "includes symlink information about entries", -> + entries = directory.getEntries() + for entry in entries + name = entry.getBaseName() + if name is 'symlink-to-dir' or name is 'symlink-to-file' + expect(entry.symlink).toBeTruthy() + else + expect(entry.symlink).toBeFalsy() describe ".relativize(path)", -> - it "returns a relative path based on the directory's path", -> - absolutePath = directory.getPath() - expect(directory.relativize(absolutePath)).toBe '' - expect(directory.relativize(path.join(absolutePath, "b"))).toBe "b" - expect(directory.relativize(path.join(absolutePath, "b/file.coffee"))).toBe "b/file.coffee" - expect(directory.relativize(path.join(absolutePath, "file.coffee"))).toBe "file.coffee" + describe "on #darwin or #linux", -> + it "returns a relative path based on the directory's path", -> + absolutePath = directory.getPath() + expect(directory.relativize(absolutePath)).toBe '' + expect(directory.relativize(path.join(absolutePath, "b"))).toBe "b" + expect(directory.relativize(path.join(absolutePath, "b/file.coffee"))).toBe "b/file.coffee" + expect(directory.relativize(path.join(absolutePath, "file.coffee"))).toBe "file.coffee" - it "returns a relative path based on the directory's symlinked source path", -> - symlinkPath = path.join(__dirname, 'fixtures', 'symlink-to-dir') - symlinkDirectory = new Directory(symlinkPath) - realFilePath = require.resolve('./fixtures/dir/a') - expect(symlinkDirectory.relativize(symlinkPath)).toBe '' - expect(symlinkDirectory.relativize(realFilePath)).toBe 'a' + it "returns a relative path based on the directory's symlinked source path", -> + symlinkPath = path.join(__dirname, 'fixtures', 'symlink-to-dir') + symlinkDirectory = new Directory(symlinkPath) + realFilePath = require.resolve('./fixtures/dir/a') + expect(symlinkDirectory.relativize(symlinkPath)).toBe '' + expect(symlinkDirectory.relativize(realFilePath)).toBe 'a' - it "returns the full path if the directory's path is not a prefix of the path", -> - expect(directory.relativize('/not/relative')).toBe '/not/relative' + it "returns the full path if the directory's path is not a prefix of the path", -> + expect(directory.relativize('/not/relative')).toBe '/not/relative' + + describe "on #win32", -> + it "returns a relative path based on the directory's path", -> + absolutePath = directory.getPath() + expect(directory.relativize(absolutePath)).toBe '' + expect(directory.relativize(path.join(absolutePath, "b"))).toBe "b" + expect(directory.relativize(path.join(absolutePath, "b/file.coffee"))).toBe "b\\file.coffee" + expect(directory.relativize(path.join(absolutePath, "file.coffee"))).toBe "file.coffee" + + it "returns the full path if the directory's path is not a prefix of the path", -> + expect(directory.relativize('/not/relative')).toBe "\\not\\relative" describe ".contains(path)", -> it "returns true if the path is a child of the directory's path", -> @@ -100,11 +113,12 @@ describe "Directory", -> expect(directory.contains(path.join(absolutePath, "b", "file.coffee"))).toBe true expect(directory.contains(path.join(absolutePath, "file.coffee"))).toBe true - it "returns true if the path is a child of the directory's symlinked source path", -> - symlinkPath = path.join(__dirname, 'fixtures', 'symlink-to-dir') - symlinkDirectory = new Directory(symlinkPath) - realFilePath = require.resolve('./fixtures/dir/a') - expect(symlinkDirectory.contains(realFilePath)).toBe true - it "returns false if the directory's path is not a prefix of the path", -> expect(directory.contains('/not/relative')).toBe false + + describe "on #darwin or #linux", -> + it "returns true if the path is a child of the directory's symlinked source path", -> + symlinkPath = path.join(__dirname, 'fixtures', 'symlink-to-dir') + symlinkDirectory = new Directory(symlinkPath) + realFilePath = require.resolve('./fixtures/dir/a') + expect(symlinkDirectory.contains(realFilePath)).toBe true