Skip to content

Commit

Permalink
Merge pull request #164 from jakemmarsh/browserify-tests
Browse files Browse the repository at this point in the history
Preprocess test files with Browserify
  • Loading branch information
jakemmarsh committed Mar 1, 2016
2 parents 07e64e6 + 4a0da5a commit 04395ed
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-gulp-browserify-boilerplate",
"version": "1.5.1",
"version": "1.5.2",
"author": "Jake Marsh <[email protected]>",
"description": "Boilerplate using AngularJS, SASS, Gulp, and Browserify while also utilizing best practices.",
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const karmaBaseConfig = {
frameworks: ['jasmine', 'browserify'],

preprocessors: {
'app/js/**/*.js': ['browserify', 'coverage']
'app/js/**/*.js': ['browserify', 'coverage'],
'test/**/*.js': ['browserify']
},

browsers: ['Chrome'],
Expand Down
4 changes: 2 additions & 2 deletions test/unit/constants_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

describe('Unit: Constants', function() {

var constants;
let constants;

beforeEach(function() {
// instantiate the app module
angular.mock.module('app');

// mock the directive
angular.mock.inject(function(AppSettings) {
angular.mock.inject((AppSettings) => {
constants = AppSettings;
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/controllers/example_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

describe('Unit: ExampleCtrl', function() {

var ctrl;
let ctrl;

beforeEach(function() {
// instantiate the app module
angular.mock.module('app');

angular.mock.inject(function($controller) {
angular.mock.inject(($controller) => {
ctrl = $controller('ExampleCtrl');
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/directives/example_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Unit: ExampleDirective', function() {
spyOn(window, 'alert');
angular.mock.module('app');

angular.mock.inject(function($compile, $rootScope) {
angular.mock.inject(($compile, $rootScope) => {
scope = $rootScope;
scope.title = 'A sample title';
scope.message = 'A sample message';
Expand Down
8 changes: 4 additions & 4 deletions test/unit/filters/example_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

describe('Unit: ExampleFilter', function() {

var $filter;
let $filter;

beforeEach(function() {
// instantiate the app module
angular.mock.module('app');

// mock the filter
angular.mock.inject(function(_$filter_) {
angular.mock.inject((_$filter_) => {
$filter = _$filter_;
});
});

it('should replace the word "keyboard" with "leopard"', function() {
var testString = 'computers are operated by keyboards';
var resultString = $filter('ExampleFilter')(testString);
const testString = 'computers are operated by keyboards';
const resultString = $filter('ExampleFilter')(testString);

expect(resultString).toEqual('computers are operated by leopards');
});
Expand Down
8 changes: 4 additions & 4 deletions test/unit/services/example_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

describe('Unit: ExampleService', function() {

var http, service;
let http, service;

beforeEach(function() {
// instantiate the app module
angular.mock.module('app');

// mock the service
angular.mock.inject(function($httpBackend, ExampleService) {
angular.mock.inject(($httpBackend, ExampleService) => {
http = $httpBackend;
service = ExampleService;
});
Expand All @@ -24,9 +24,9 @@ describe('Unit: ExampleService', function() {
it('should retrieve data', function(done) {
http.expect('GET', 'apiPath').respond(201, {data: 1234});

service.get().then(function(result) {
service.get().then((result) => {
expect(result).toEqual({data: 1234});
}, function(error) {
}).catch((error) => {
expect(error).toBeUndefined();
}).then(done);

Expand Down

0 comments on commit 04395ed

Please sign in to comment.