Sha256: 0f83695c50b77dc9fb1614a62b269c83d917c2bd58f11adc325cb999a3a46c73

Contents?: true

Size: 1.44 KB

Versions: 62

Compression:

Stored size: 1.44 KB

Contents

var fs = require("fs");
var path = require("path");
var rimraf = require("rimraf");

var watcherManager = require("../../lib/watcherManager");

function TestHelper(testdir) {
	this.testdir = testdir;
	var self = this;
	this.before = function(done) {
		self._before(done);
	};
	this.after = function(done) {
		self._after(done);
	};
}
module.exports = TestHelper;

TestHelper.prototype._before = function before(done) {
	Object.keys(watcherManager.directoryWatchers).should.be.eql([]);
	this.tick(function() {
		rimraf.sync(this.testdir);
		fs.mkdirSync(this.testdir);
		done();
	}.bind(this));
};

TestHelper.prototype._after = function after(done) {
	this.tick(function() {
		rimraf.sync(this.testdir);
		Object.keys(watcherManager.directoryWatchers).should.be.eql([]);
		done();
	}.bind(this));
};

TestHelper.prototype.dir = function dir(name) {
	fs.mkdirSync(path.join(this.testdir, name));
};

TestHelper.prototype.file = function file(name) {
	fs.writeFileSync(path.join(this.testdir, name), Math.random() + "", "utf-8");
};

TestHelper.prototype.mtime = function mtime(name, mtime) {
	var stats = fs.statSync(path.join(this.testdir, name));
	fs.utimesSync(path.join(this.testdir, name), stats.atime, new Date(mtime));
};

TestHelper.prototype.remove = function remove(name) {
	rimraf.sync(path.join(this.testdir, name));
};

TestHelper.prototype.tick = function tick(fn) {
	// setTimeout(fn, 100);
	setTimeout(function() {
		// console.log("tick");
		fn();
	}, 100);
};

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.268 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.267 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.266 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.265 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.264 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.263 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.262 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.261 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.260 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.259 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.258 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.256 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.255 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.254 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.253 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.252 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.251 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.250 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.249 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js
smock-0.1.247 node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js