Skip to content

Commit

Permalink
Update Lesson 4 content
Browse files Browse the repository at this point in the history
  • Loading branch information
hbkwong committed Sep 21, 2018
1 parent 20a5907 commit 5d5bc20
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
68 changes: 40 additions & 28 deletions Lesson 4/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*eslint-env node */

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var eslint = require('gulp-eslint');
var jasmine = require('gulp-jasmine-phantom');
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const eslint = require('gulp-eslint');
const jasmineBrowser = require('gulp-jasmine-browser');

gulp.task('default', ['styles', 'lint'], function() {
gulp.watch('sass/**/*.scss', ['styles']);
Expand All @@ -17,32 +17,44 @@ gulp.task('default', ['styles', 'lint'], function() {
});

gulp.task('styles', function() {
gulp.src('sass/**/*.scss')
gulp
.src('sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(
autoprefixer({
browsers: ['last 2 versions']
})
)
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
});

gulp.task('lint', function () {
return gulp.src(['js/**/*.js'])
// eslint() attaches the lint output to the eslint property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError());
gulp.task('lint', function() {
return (
gulp
.src(['js/**/*.js'])
// eslint() attaches the lint output to the eslint property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError())
);
});

gulp.task('tests', function () {
gulp.src('tests/spec/extraSpec.js')
.pipe(jasmine({
integration: true,
vendor: 'js/**/*.js'
}));
});
gulp.task('tests', function() {
return gulp
.src('tests/spec/extraSpec.js')
.pipe(jasmineBrowser.specRunner({ console: true }))
.pipe(jasmineBrowser.headless({ driver: 'chrome' }));
});

// gulp.task('tests', function() {
// gulp
// .src('tests/spec/extraSpec.js')
// .pipe(jasmineBrowser.specRunner())
// .pipe(jasmineBrowser.server({ port: 3001 }));
// });
2 changes: 1 addition & 1 deletion Lesson 4/js/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ function getWindowHeight() {
return window.innerHeight;
}

getWindowHeight();
getWindowHeight();
4 changes: 1 addition & 3 deletions Lesson 4/js/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(function() {

var foo = 1;
return foo;

})();
})();
14 changes: 13 additions & 1 deletion Lesson 4/tests/spec/extraSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
describe('window height', function() {
it('returns window height', function() {
function getWindowHeight() {
return window.innerHeight;
}

getWindowHeight();

expect(getWindowHeight()).toEqual(jasmine.any(Number));
});
});
});

describe('document', function() {
it('document is defined', function() {
expect(document).toBeDefined();
});
});

0 comments on commit 5d5bc20

Please sign in to comment.