it("should support isDirectory()", function() { waitsFor(helper.testComplete, "Stat isFile", 5); helper.writeFixture(function(sut) { var stats = fs.statSync(sut.getParent()); expect(stats).toBeTruthy(); expect(stats.isDirectory()).toBeTruthy(); sut.delete(); helper.testComplete(true); }); });
it("should return an fs.ReadStream", function() { waitsFor(helper.testComplete, 5); helper.writeFixture(function(f) { var readStream = fs.createReadStream(f.getAbsolutePath()); expect(readStream).toBeTruthy(); expect(readStream instanceof fs.ReadStream).toBeTruthy(); expect(readStream instanceof stream.Readable).toBeTruthy(); f.delete(); helper.testComplete(true); }); });
it("should emit 'close' when it has been destroyed", function() { waitsFor(helper.testComplete, 5); helper.writeFixture(function(f) { var readStream = fs.createReadStream(f.getAbsolutePath()); readStream.on('data', function(chunk) { readStream.on('close', function() { helper.testComplete(true); }); readStream.destroy(); }); }); });
it("should support isDirectory()", function() { waitsFor(helper.testComplete, "Stat isFile", 5); helper.writeFixture(function(sut) { fs.stat(sut.getParent(), function(err, stats) { expect(err).toBe(null); expect(stats).not.toBe(null); expect(stats).not.toBe(undefined); expect(stats.isDirectory()).toBeTruthy(); sut.delete(); helper.testComplete(true); }); }); });
it("should emit 'open' when the file has opened.", function() { var data = "Now is the winter of our discontent / " + "Made glorious summer by this son of York"; waitsFor(helper.testComplete, 5); helper.writeFixture(function(f) { var result = '', readStream = fs.createReadStream(f.getAbsolutePath()); readStream.on('open', function() { f.delete(); helper.testComplete(true); }); }, data); });
it("should read files.", function() { var data = "Now is the winter of our discontent / " + "Made glorious summer by this son of York"; waitsFor(helper.testComplete, 5); helper.writeFixture(function(f) { var result = '', readStream = fs.createReadStream(f.getAbsolutePath()); readStream.on('data', function(chunk) { result += chunk; }); readStream.on('end', function() { expect(result).toEqual(data); f.delete(); helper.testComplete(true); }); }, data); });