gulp-spawn
Version: 
spawn plugin for gulp
53 lines (45 loc) • 1.01 kB
JavaScript
import assert from 'node:assert';
import Vinyl from 'vinyl';
import gSpawn from '../index.js';
describe('gulp-spawn', () => {
	it('should pass null files through', done => {
		const stream = gSpawn({
			cmd: 'cat',
		});
		let count = 0;
		const fakeFile = new Vinyl({
			cwd: './',
			base: 'test',
			path: 'test/file.js',
			contents: null,
		});
		const fakeFile2 = new Vinyl({
			cwd: './',
			base: 'test',
			path: 'test/file2.js',
			contents: null,
		});
		stream.on('readable', () => {
			let newFile;
			while ((newFile = stream.read())) {
				assert(newFile);
				assert.equal(newFile.cwd, './');
				assert.equal(newFile.base, 'test');
				assert.equal(newFile.contents, null);
				count += 1;
				if (count === 1) {
					assert.equal(newFile.path, 'test/file.js');
				} else {
					assert.equal(newFile.path, 'test/file2.js');
				}
			}
		});
		stream.on('end', () => {
			assert.equal(count, 2);
			done();
		});
		stream.write(fakeFile);
		stream.write(fakeFile2);
		stream.end();
	});
});