UNPKG

gulp-notify

Version:

A plugin for Gulp to send messages to Mac Notification Center

118 lines (101 loc) 3.3 kB
/*global describe, it*/ "use strict"; var gulp = require('gulp'), should = require('should'), join = require('path').join, notify = require('../'); var mockGenerator = function (tester) { return function (opts, callback) { tester(opts); callback(); }; }; describe('gulp output stream', function() { describe('notify()', function() { it('should return a stream', function(done) { var stream = notify({ notifier: mockGenerator() }); should.exist(stream); should.exist(stream.on); should.exist(stream.pipe); done(); }); it('should call notifier with title and message', function(done) { var testString = "this is a test", instream = gulp.src(join(__dirname, "./fixtures/*.txt")), outstream = notify({ message: testString, notifier: mockGenerator(function (opts) { should.exist(opts); should.exist(opts.title); should.exist(opts.message); String(opts.message).should.equal(testString); }) }); outstream.on('data', function(file) { should.exist(file); should.exist(file.path); should.exist(file.contents); }); outstream.on('end', function() { done(); }); instream.pipe(outstream); }); it('should default to notifying file path and default title', function(done) { var srcFile = join(__dirname, "./fixtures/1.txt"); var instream = gulp.src(srcFile), outstream = notify({ notifier: mockGenerator(function (opts) { should.exist(opts); should.exist(opts.title); should.exist(opts.message); String(opts.message).should.equal(srcFile); String(opts.title).should.equal("Gulp notification"); }) }); outstream.on('data', function(file) { should.exist(file); should.exist(file.path); should.exist(file.contents); }); outstream.on('end', function() { done(); }); instream.pipe(outstream); }); it('should take function with file as argument, as message or title', function(done) { var testSuffix = "tester", srcFile = join(__dirname, "./fixtures/1.txt"), instream = gulp.src(srcFile), outstream = notify({ notifier: mockGenerator(function (opts) { should.exist(opts); should.exist(opts.title); should.exist(opts.message); String(opts.message).should.equal(srcFile + testSuffix); String(opts.title).should.equal(srcFile + testSuffix); }), message: function (file) { String(file.path).should.equal(srcFile); return file.path + testSuffix; }, title: function (file) { String(file.path).should.equal(srcFile); return file.path + testSuffix; } }); outstream.on('data', function(file) { should.exist(file); should.exist(file.path); should.exist(file.contents); }); outstream.on('end', function() { done(); }); instream.pipe(outstream); }); }); });