Commit ad01aaad authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[TASK] tests for the recent changes

parent 4e2c5a1b
......@@ -7,28 +7,21 @@ var gulp = require('gulp'),
require('require-dir')('./gulp');
gulp.task('watch', function() {
<% if (projectType == 'typo3Frontend') { %>
gulp.watch('typo3conf/ext/**/*.scss').on('change', function(file) {
<% if (projectType == 'typo3Frontend') { %>gulp.watch('typo3conf/ext/**/*.scss').on('change', function(file) {
settings.setExtension(getExtensionName(file));
gulp.start('css');
});
gulp.watch(['typo3conf/ext/**/*.js', '!' + 'typo3conf/ext/**/*.min.js']).on('change', function(file) {
settings.setExtension(getExtensionName(file));
gulp.start('javascript');
});
<% } else { %>
gulp.watch(settings.path().sass + '/**/*.scss', ['css']);
gulp.watch([settings.path().javascript + '/**/*.js', '!' + settings.path().javascript + '/**/*.min.js'], ['javascript']);
<% } %>
});<% } else { %>gulp.watch(settings.path().sass + '/**/*.scss', ['css']);
gulp.watch([settings.path().javascript + '/**/*.js', '!' + settings.path().javascript + '/**/*.min.js'], ['javascript']);<% } %>
});
gulp.task('default', function() {
<% if (projectType == 'typo3Frontend') { %>
settings.setExtension('');
<% } %>
gulp.start('browser-sync', 'watch');
<% if (projectType == 'typo3Frontend') { %>settings.setExtension('');
<% } %>gulp.start('browser-sync', 'watch');
});
<% if (projectType == 'typo3Frontend') { %>
function getExtensionName(changedFile) {
var ext = changedFile.path.split('ext/')[1].split('/')[0];
......
gulp.watch(settings.path.sass + '/**/*.scss', ['css']).on('change', function(file) {
livereload.changed(file.path);
});
gulp.watch([settings.path.javascript + '/**/*.js', '!' + settings.path.javascript + '/**/*.min.js'], ['javascript']).on('change', function(file) {
livereload.changed(file.path);
});
......@@ -15,11 +15,6 @@ describe('sgalinski generator:standalone:bower', function() {
.withPrompt({
projectType: 'standalone',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\''
})
.on('end', done);
});
......@@ -40,11 +35,6 @@ describe('sgalinski generator:standalone:withoutBower', function() {
.withPrompt({
projectType: 'standalone',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\'',
bower: false
})
.on('end', done);
......@@ -66,11 +56,6 @@ describe('sgalinski generator:typo3-frontend:bower', function() {
.withPrompt({
projectType: 'typo3Frontend',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\'',
bower: true
})
.on('end', done);
......@@ -92,12 +77,6 @@ describe('sgalinski generator:typo3-frontend:withoutBower', function() {
.withPrompt({
projectType: 'typo3Frontend',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
compassConfigPath: '.',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\'',
bower: false
})
.on('end', done);
......
......@@ -39,7 +39,8 @@ describe('sgalinski generator:standalone', function() {
'gulp/css.js',
'gulp/images.js',
'gulp/javascript.js',
'gulp/settings.js'
'gulp/settings.js',
'gulp/browser-sync.js'
]);
});
......@@ -66,81 +67,3 @@ describe('sgalinski generator:standalone', function() {
});
});
});
describe('sgalinski generator:standalone:browsersync', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'standalone',
projectName: 'test',
autoprefixerBrowserSelection: '\'last 1 version\'',
livereloadMethod: 'browserSync'
})
.on('end', done);
});
it('copies the browserSync task', function() {
assert.file([
'gulp/browser-sync.js'
]);
});
it('adds the browsersync reload call to the css setup', function() {
assert.fileContent('gulp/css.js', '.pipe(browserSync.reload({stream: true}));');
});
it('adds the browsersync reload call to the js setup', function() {
assert.fileContent('gulp/javascript.js', '.pipe(browserSync.reload({stream: true}));');
});
it('does not add .on event handlers for livereload', function(done) {
fs.readFile(path.join(__dirname, 'livereload-on-change-eventhandler.txt'), 'utf-8', function(err, notExpected) {
if (err) {
throw err;
}
assert.noFileContent('gulpfile.js', notExpected);
done();
});
});
});
describe('sgalinski generator:standalone:livereload', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'standalone',
projectName: 'test',
autoprefixerBrowserSelection: '\'last 1 version\'',
livereloadMethod: 'livereload'
})
.on('end', done);
});
it('does not copy the browserSync task', function() {
assert.noFile([
'gulp/browser-sync.js'
]);
});
it('does not add the browsersync reload call to the css setup', function() {
assert.noFileContent('gulp/css.js', '.pipe(browserSync.reload({stream: true}));');
});
it('does not add the browsersync reload call to the js setup', function() {
assert.noFileContent('gulp/javascript.js', '.pipe(browserSync.reload({stream: true}));');
});
it('adds .on event handlers for livereload', function(done) {
fs.readFile(path.join(__dirname, 'livereload-on-change-eventhandler.txt'), 'utf-8', function(err, expected) {
if (err) {
throw err;
}
assert.fileContent('gulpfile.js', expected);
done();
});
});
});
......@@ -15,8 +15,7 @@ describe('sgalinski generator:typo3-frontend', function() {
.withPrompt({
projectType: 'typo3Frontend',
projectName: 'test',
autoprefixerBrowserSelection: '\'last 1 version\'',
compass: true
autoprefixerBrowserSelection: '\'last 1 version\''
})
.on('end', done);
});
......@@ -39,7 +38,8 @@ describe('sgalinski generator:typo3-frontend', function() {
'gulp/css.js',
'gulp/images.js',
'gulp/javascript.js',
'gulp/settings.js'
'gulp/settings.js',
'gulp/browser-sync.js'
]);
});
......@@ -61,77 +61,8 @@ describe('sgalinski generator:typo3-frontend', function() {
});
});
});
describe('sgalinski generator:typo3-frontend:browsersync', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'typo3Frontend',
projectName: 'test',
autoprefixerBrowserSelection: '\'last 1 version\'',
livereloadMethod: 'browserSync'
})
.on('end', done);
});
it('copies the browserSync task', function() {
assert.file([
'gulp/browser-sync.js'
]);
});
it('adds the browsersync reload call to the css setup', function() {
assert.fileContent('gulp/css.js', '.pipe(browserSync.reload({stream: true}));');
});
it('adds the browsersync reload call to the js setup', function() {
assert.fileContent('gulp/javascript.js', '.pipe(browserSync.reload({stream: true}));');
});
it('does not add .on event handlers for livereload', function(done) {
fs.readFile(path.join(__dirname, 'livereload-on-change-eventhandler.txt'), 'utf-8', function(err, notExpected) {
if (err) {
throw err;
}
assert.noFileContent('gulpfile.js', notExpected);
done();
});
});
});
describe('sgalinski generator:typo3-frontend:livereload', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'typo3Frontend',
projectName: 'test',
autoprefixerBrowserSelection: '\'last 1 version\'',
livereloadMethod: 'livereload'
})
.on('end', done);
});
it('does not copy the browserSync task', function() {
assert.noFile([
'gulp/browser-sync.js'
]);
});
it('does not add the browsersync reload call to the css setup', function() {
assert.noFileContent('gulp/css.js', '.pipe(browserSync.reload({stream: true}));');
});
it('does not add the browsersync reload call to the js setup', function() {
assert.noFileContent('gulp/javascript.js', '.pipe(browserSync.reload({stream: true}));');
});
it('adds .on event handlers for livereload', function(done) {
fs.readFile(path.join(__dirname, 'livereload-on-change-eventhandler.txt'), 'utf-8', function(err, expected) {
it('creates the extension name handling functions', function(done) {
fs.readFile(path.join(__dirname, 'typo3-frontend-extension-name-handling.txt'), 'utf-8', function(err, expected) {
if (err) {
throw err;
}
......@@ -139,4 +70,5 @@ describe('sgalinski generator:typo3-frontend:livereload', function() {
done();
});
});
});
gulp.task('watch', function() {
gulp.watch('typo3conf/ext/**/*.scss').on('change', function(file) {
settings.setExtension(getExtensionName(file));
gulp.start('css');
});
gulp.watch(['typo3conf/ext/**/*.js', '!' + 'typo3conf/ext/**/*.min.js']).on('change', function(file) {
settings.setExtension(getExtensionName(file));
gulp.start('javascript');
});
});
gulp.task('default', function() {
settings.setExtension('');
gulp.start('browser-sync', 'watch');
});
function getExtensionName(changedFile) {
var ext = changedFile.path.split('ext/')[1].split('/')[0];
gutil.log('Change in extension [' + ext + ']');
return ext;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment