UNPKG

2.01 kBJavaScriptView Raw
1process.chdir('./test');
2
3var test = require('tape');
4var modul = require('../');
5
6var exec = require('child_process').exec;
7var fs = require('fs');
8var stream = require('stream');
9
10test('gulp compliance test', function (t) {
11 t.plan(7);
12
13 t.equal(typeof modul, "function", 'gulp-tasks should be a function');
14 var gulp = modul();
15
16 t.equal(typeof gulp.task, "function", 'gulp.task should be a function');
17 t.equal(typeof gulp.src, "function", 'gulp.src should be a function');
18 t.equal(typeof gulp.src('./**').on, 'function', 'gulp.src(\'./**\') should return a readable stream');
19 t.equal(typeof gulp.dest, "function", 'gulp.dest should be a function');
20 t.equal(typeof gulp.dest('./').on, 'function', 'gulp.dest(\'./\') should return a writable stream');
21 t.equal(typeof gulp.watch, "function", 'gulp.watch should be a function');
22});
23
24test('gulp extension test', function (t) {
25 t.plan(4);
26 var gulp = modul();
27
28 t.equal(typeof gulp.src().on, 'function', 'gulp.src() should return a readable stream');
29 t.equal(typeof gulp.dest().on, 'function', 'gulp.dest() should return a writable stream');
30 var name = gulp.name;
31 t.equal(typeof name, 'string', 'gulp.name should return a string');
32 gulp.name = 'hahaha';
33 t.equal(name, gulp.name, 'gulp.name should not be modifiable');
34});
35
36function checkFile(t, file, msg) {
37 try {
38 t.ok(fs.statSync(file).isFile(), msg);
39 } catch (ex) {
40 t.fail(msg);
41 }
42}
43
44test('functionality test', function (t) {
45 t.plan(4);
46
47 exec('gulp', function (error, stdout, stderr) {
48 t.error(error, 'gulp command should execute without errors');
49
50 checkFile(t, './test/copied-dummy.js', 'gulp should have created a new file in test');
51 });
52
53 exec('gulp --target=production', function (error, stdout, stderr) {
54 t.error(error, 'gulp command should execute without errors');
55
56 checkFile(t, './dist/copied-dummy.js', 'gulp should have created a new file in dist');
57 });
58});
\No newline at end of file