Skip to content

Commit

Permalink
Build up the unit testing infrastructure with Karma, Mocha, and Chai;…
Browse files Browse the repository at this point in the history
… refine Gruntfile.js
  • Loading branch information
Gias Kay Lee committed Oct 16, 2013
1 parent 2f36c9c commit 9adb17f
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "components"
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
components
.DS_Store
node_modules
69 changes: 48 additions & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,50 @@
'use strict';

module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

karma: {
unit: {
options: {
files: [
'components/angular/angular.js',
'components/angular-mocks/angular-mocks.js',
'components/chai/chai.js',
'ngStorage.js',
'test/spec.js'
]
},

frameworks: ['mocha'],

browsers: [
'Chrome',
'PhantomJS',
'Firefox'
],

singleRun: true
}
},

uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> | Copyright (c) <%= grunt.template.today("yyyy") %> Gias Kay Lee | MIT License */'
},

build: {
src: '<%= pkg.name %>.js',
dest: '<%= pkg.name %>.min.js'
}
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-karma');

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: '<%= pkg.name %>.js',
dest: '<%= pkg.name %>.min.js'
}
}
});

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');

// Default task(s).
grunt.registerTask('default', ['uglify']);

};
grunt.registerTask('default', [
'karma',
'uglify'
]);
};
14 changes: 13 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"name": "ngstorage",
"version": "0.2.3",
"main": "./ngStorage.js",
"keywords": [
"angular",
"cookie",
"storage",
"local",
"localstorage",
"session",
"sessionstorage"
],
"dependencies": {
"angular": ">=1.0.8"
},
"devDependencies": {
"angular-mocks": ">=1.0.8",
"chai": "~1.8.1"
}
}
3 changes: 1 addition & 2 deletions ngStorage.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 16 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
{
"name": "ngStorage",
"version": "0.2.3",
"description": "An AngularJS module that makes Web Storage working in the Angular Way. Contains two services: $localStorage and $sessionStorage.",
"main": "ngStorage.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/gsklee/ngStorage.git"
},
"author": "gsklee",
"license": "MIT",
"bugs": {
"url": "https://github.com/gsklee/ngStorage/issues"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.4"
}
"name": "ngStorage",
"version": "0.2.3",
"private": true,
"author": "Gias Kay Lee",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/gsklee/ngStorage/blob/master/LICENSE"
}
],
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.4",
"grunt-karma": "~0.7.1",
"karma-mocha": "~0.1.0"
}
}
13 changes: 13 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

describe('ngStorage', function () {
var expect = chai.expect;

beforeEach(module('ngStorage'));

it('should contain a $localStorage service', inject(function(
$localStorage
){
expect($localStorage).not.to.equal(null);
}));
});

0 comments on commit 9adb17f

Please sign in to comment.