Skip to content

Commit

Permalink
Merge pull request #217 from jpbackman/angular-test-cleanup
Browse files Browse the repository at this point in the history
Test refactoring cleanup
  • Loading branch information
hannu committed Nov 20, 2014
2 parents 506cabb + 2fac9ad commit aac0eda
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 34 deletions.
48 changes: 21 additions & 27 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ function getBuildOptions() {
}, options, config);
}

function getKarmaConfig(configFile) {
var config = {},
setter = {
set: function(opts) {
config = opts;
}
};
require(configFile)(setter);
return config;
}

gulp.task('jscs', function() {
return gulp.src([
'lib/**/*.js',
Expand Down Expand Up @@ -224,31 +235,12 @@ gulp.task('test:integration', function() {
});

gulp.task('test:functional', function() {
var files = [
// components
'lib/app/js/components/angular/angular.js',
'lib/app/js/components/ui-router/release/angular-ui-router.js',
'lib/app/js/components/angular-animate/angular-animate.js',
'lib/app/js/components/angular-bootstrap-colorpicker/js/bootstrap-colorpicker-module.js',
'lib/app/js/components/angular-local-storage/dist/angular-local-storage.js',
'lib/app/js/components/highlightjs/highlight.pack.js',
'lib/app/js/components/angular-highlightjs/angular-highlightjs.js',
'lib/app/js/components/oclazyload/dist/ocLazyLoad.js',
'lib/app/js/components/angular-mocks/angular-mocks.js',
'lib/app/js/components/ngprogress/build/ngProgress.js',
// application code
'lib/app/js/*.js',
'lib/app/js/controllers/*.js',
'lib/app/js/directives/*.js',
'lib/app/js/services/*.js',
// tests
'test/angular/**/*.js'
];
return gulp.src(files)
.pipe(karma({
configFile: 'test/karma.conf.js',
var karmaOpts = {
configFile: './test/karma.conf.js',
action: 'run'
}));
};
return gulp.src(getKarmaConfig(karmaOpts.configFile).files)
.pipe(karma(karmaOpts));
});

gulp.task('test', function(done) {
Expand All @@ -257,16 +249,18 @@ gulp.task('test', function(done) {

gulp.task('test-coverage', ['test'], function() {
var collector = new coverage.Collector(),
report = coverage.Report.create('lcov', {
lcov = coverage.Report.create('lcov', {
dir: 'coverage'
});
}),
summary = coverage.Report.create('text-summary');

return gulp.src('coverage/*.json')
.pipe(through.obj(function(file, enc, done) {
collector.add(JSON.parse(file.contents.toString()));
done();
}, function(callback) {
report.writeReport(collector);
lcov.writeReport(collector);
summary.writeReport(collector);
callback();
}));
});
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/io.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var fs = require('fs'),
path = require('path'),
parser = require('./parser');
parser = require('./variable-parser');

module.exports = function(ioServer, options) {

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/styleguide.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var through = require('through2'),
rename = require('gulp-rename'),
markdown = require(__dirname + '/modules/markdown'),
mustache = require('gulp-mustache'),
parser = require(__dirname + '/modules/parser'),
parseKSS = require(__dirname + '/modules/kss').parseKSS,
variableParser = require(__dirname + '/modules/variable-parser'),
parseKSS = require(__dirname + '/modules/kss-parser').parseKSS,
pseudoSelectors = require(__dirname + '/modules/pseudo-selectors'),
preprocess = require(__dirname + '/modules/preprocess'),
wrapperMarkup = require(__dirname + '/modules/wrapper-markup'),
Expand Down Expand Up @@ -85,11 +85,11 @@ function appendUsedVariablesToEachBlock(opt, styleguide) {
if (opt.styleVariables) {
var syntax = path.extname(opt.styleVariables).substring(1);
// Parse variables from the defined file
styleguide.config.settings = parser.parseVariables(fs.readFileSync(opt.styleVariables, 'utf-8'), syntax);
styleguide.config.settings = variableParser.parseVariables(fs.readFileSync(opt.styleVariables, 'utf-8'), syntax);
// Go trough every styleguide style block and find used variables
styleguide.sections.forEach(function(section) {
if (section.css) {
section.variables = parser.findVariables(section.css, syntax);
section.variables = variableParser.findVariables(section.css, syntax);
}
return section;
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ module.exports = function(config) {
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'sinon-chai'],

// list of files / patterns to load in the browser
files: [
// components
'lib/app/js/components/angular/angular.js',
'lib/app/js/components/ui-router/release/angular-ui-router.js',
'lib/app/js/components/angular-animate/angular-animate.js',
'lib/app/js/components/angular-bootstrap-colorpicker/js/bootstrap-colorpicker-module.js',
'lib/app/js/components/angular-local-storage/dist/angular-local-storage.js',
'lib/app/js/components/highlightjs/highlight.pack.js',
'lib/app/js/components/angular-highlightjs/angular-highlightjs.js',
'lib/app/js/components/oclazyload/dist/ocLazyLoad.js',
'lib/app/js/components/angular-mocks/angular-mocks.js',
'lib/app/js/components/ngprogress/build/ngProgress.js',
// application code
'lib/app/js/*.js',
'lib/app/js/controllers/*.js',
'lib/app/js/directives/*.js',
'lib/app/js/services/*.js',
// tests
'test/angular/**/*.js'
],

// list of files to exclude
exclude: [
'test/structure.js'
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/modules/kss-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var requireModule = require('requirefrom')('lib/modules'),
chai = require('chai'),
expect = chai.expect,
multiline = require('multiline'),
parser = requireModule('kss');
parser = requireModule('kss-parser');

describe('KSS parser', function() {
var files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var requireModule = require('requirefrom')('lib/modules'),
chai = require('chai'),
expect = chai.expect,
multiline = require('multiline'),
parser = requireModule('parser');
parser = requireModule('variable-parser');

describe('Parser', function() {
describe('variable finding', function() {
Expand Down

0 comments on commit aac0eda

Please sign in to comment.