+
+
+
+
+
+
+
+ {{parcel.location}}
+
+
+
+
+
+
+
+
diff --git a/tinasharma/gulpfile.js b/tinasharma/gulpfile.js
new file mode 100644
index 0000000..4f75f85
--- /dev/null
+++ b/tinasharma/gulpfile.js
@@ -0,0 +1,60 @@
+var gulp = require('gulp');
+var webpack = require('webpack-stream');
+var minifyCss = require('gulp-minify-css');
+var concatCSS = require('gulp-concat-css');
+var gulpWatch = require('gulp-watch');
+var sass = require('gulp-sass');
+var maps = require('gulp-sourcemaps');
+
+gulp.task('static:dev',function() {
+ gulp.src('app/**/*.html')
+ .pipe(gulp.dest('build/'));
+});
+
+// gulp.task('css:dev', function() {
+// return gulp.src([
+// 'app/css/reset.css',
+// 'app/css/base.css',
+// 'app/css/layout.css',
+// 'app/css/module.css',
+// 'app/css/state.css',])
+// .pipe(concatCss('styles.min.css'))
+// .pipe(minifyCss())
+// .pipe(gulp.dest('build/'));
+// });
+
+gulp.task('sass:dev', function() {
+ gulp.src('./app/sass/**/*.scss')
+ .pipe(maps.init())
+ .pipe(sass().on('error', sass.logError))
+ .pipe(minifyCss())
+ .pipe(maps.write('./'))
+ .pipe(gulp.dest('build/'));
+});
+
+gulp.task('sass:watch', function() {
+ gulp.watch(['./app/sass/**/*.scss', './app/index.html'],['sass:dev', 'static:dev']);
+});
+
+gulp.task('webpack:dev',function() {
+ return gulp.src('app/js/entry.js')
+ .pipe(webpack({
+ output: {
+ filename: 'bundle.js'
+ }
+ }))
+ .pipe(gulp.dest('build/'));
+});
+
+gulp.task('webpack:test', function() {
+ return gulp.src('test/client/test_entry.js')
+ .pipe(webpack({
+ output: {
+ filename: 'test_bundle.js'
+ }
+ }))
+ .pipe(gulp.dest('test/client/'));
+});
+
+gulp.task('build:dev', ['webpack:dev', 'static:dev', 'sass:dev']);
+gulp.task('default', ['build:dev']);
diff --git a/tinasharma/karma.conf.js b/tinasharma/karma.conf.js
new file mode 100644
index 0000000..7efea19
--- /dev/null
+++ b/tinasharma/karma.conf.js
@@ -0,0 +1,69 @@
+// Karma configuration
+// Generated on Thu Dec 03 2015 10:08:49 GMT-0800 (PST)
+
+module.exports = function(config) {
+ config.set({
+
+ // base path that will be used to resolve all patterns (eg. files, exclude)
+ basePath: '',
+
+
+ // frameworks to use
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+ frameworks: ['jasmine'],
+
+
+ // list of files / patterns to load in the browser
+ files: [
+ 'test/client/test_bundle.js'
+ ],
+
+
+ // list of files to exclude
+ exclude: [
+ ],
+
+
+ // preprocess matching files before serving them to the browser
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+ preprocessors: {
+ },
+
+
+ // test results reporter to use
+ // possible values: 'dots', 'progress'
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+ reporters: ['progress'],
+
+
+ // web server port
+ port: 9876,
+
+
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+
+
+ // level of logging
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+ logLevel: config.LOG_INFO,
+
+
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: false,
+
+
+ // start these browsers
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+ browsers: ['PhantomJS'],
+
+
+ // Continuous Integration mode
+ // if true, Karma captures browsers, runs the tests and exits
+ singleRun: true,
+
+ // Concurrency level
+ // how many browser should be started simultanous
+ concurrency: Infinity
+ })
+}
diff --git a/tinasharma/models/parcel.js b/tinasharma/models/parcel.js
index 7518efe..134e97e 100644
--- a/tinasharma/models/parcel.js
+++ b/tinasharma/models/parcel.js
@@ -1,11 +1,11 @@
var mongoose = require('mongoose');
var parcelSchema = new mongoose.Schema({
+ name: String, //name of mailman
item: {type: String, default: 'mailing_packet'},
- size: String,
+ size: String, //small, medium, large
weight: {type: Number, max: 10},
location: {type: String, default: 'Seattle'}
});
module.exports = mongoose.model('Parcel', parcelSchema);
-
diff --git a/tinasharma/package.json b/tinasharma/package.json
index ba17cae..79a8165 100644
--- a/tinasharma/package.json
+++ b/tinasharma/package.json
@@ -9,13 +9,31 @@
"author": "",
"license": "MIT",
"dependencies": {
+ "bcrypt": "latest",
"body-parser": "^1.14.1",
+ "eat": "^0.1.1",
"express": "^4.13.3",
"mongoose": "^4.2.5"
},
"devDependencies": {
+ "angular": "^1.4.8",
+ "angular-mocks": "^1.4.8",
+ "angular-route": "^1.4.8",
"chai": "^3.4.1",
"chai-http": "^1.0.0",
- "mocha": "^2.3.3"
+ "gulp": "^3.9.0",
+ "gulp-autoprefixer": "^3.1.0",
+ "gulp-concat-css": "^2.2.0",
+ "gulp-minify-css": "^1.2.2",
+ "gulp-sass": "^2.1.0",
+ "gulp-sourcemaps": "^1.6.0",
+ "gulp-watch": "^4.3.5",
+ "jasmine-core": "^2.4.0",
+ "karma": "^0.13.15",
+ "karma-jasmine": "^0.3.6",
+ "karma-phantomjs-launcher": "^0.2.1",
+ "mocha": "^2.3.3",
+ "phantomjs": "^1.9.19",
+ "webpack-stream": "^2.2.0"
}
}
diff --git a/tinasharma/routes/parcels_routes.js b/tinasharma/routes/parcels_routes.js
index 7a9aec3..2fc9cb8 100644
--- a/tinasharma/routes/parcels_routes.js
+++ b/tinasharma/routes/parcels_routes.js
@@ -2,7 +2,6 @@ var express = require('express');
var bodyParser = require('body-parser');
var Parcel = require(__dirname + '/../models/parcel.js');
var handleError = require(__dirname + '/../lib/handleServerError.js');
-
var parcelsRouter = module.exports = exports = express.Router();
parcelsRouter.get('/parcels', function(req, res) {
diff --git a/tinasharma/server.js b/tinasharma/server.js
index 4ae8fa4..78ae543 100644
--- a/tinasharma/server.js
+++ b/tinasharma/server.js
@@ -1,10 +1,12 @@
var mongoose = require('mongoose');
var express = require('express');
var app = express();
-var parcelsRouter = require(__dirname + '/routes/parcels_routes.js');
+var parcelsRouter = require(__dirname + '/routes/parcels_routes.js');
mongoose.connect(process.env.MONGOLAB_URI || 'mongodb://localhost/parcel_stream_dev');
+app.use(express.static(__dirname + '/build'));
+
app.use('/api', parcelsRouter);
app.listen(process.env.PORT || 3000, function() {
diff --git a/tinasharma/test/client/parcels_controller_tests.js b/tinasharma/test/client/parcels_controller_tests.js
new file mode 100644
index 0000000..ff5096e
--- /dev/null
+++ b/tinasharma/test/client/parcels_controller_tests.js
@@ -0,0 +1,71 @@
+require(__dirname + '/../../app/js/entry.js');
+require('angular-mocks');
+
+describe('parcels controller', function() {
+ var $httpBackend;
+ var $ControllerConstructor;
+ var $scope;
+
+ beforeEach(angular.mock.module('ParcelStreamApp'));
+
+ beforeEach(angular.mock.inject(function($rootScope, $controller) {
+ $scope = $rootScope.$new();
+ $ControllerConstructor = $controller;
+ }));
+
+ it('should be able to create a controller', function() {
+ var controller = $ControllerConstructor('ParcelsController', {$scope: $scope});
+ expect(typeof $scope).toBe('object');
+ expect(typeof controller).toBe('object');
+ expect(Array.isArray($scope.parcels)).toBe(true);
+ });
+
+ describe('REST request functions', function() {
+ beforeEach(angular.mock.inject(function(_$httpBackend_, $rootScope) {
+ $httpBackend = _$httpBackend_;
+ $scope = $rootScope.$new();
+ $ControllerConstructor('ParcelsController', {$scope: $scope});
+ }));
+
+ afterEach(function() {
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
+
+ it('should add an array to parcels with a GET all', function() {
+ $httpBackend.expectGET('/api/parcels').respond(200, [{_id:1, name: 'test parcel'}]);
+ $scope.getAll();
+ $httpBackend.flush();
+ expect($scope.parcels[0].name).toBe('test parcel');
+ });
+
+ it('should be able to create a new parcel', function() {
+ $httpBackend.expectPOST('/api/parcels', {name: 'test parcel', size: 'small', weight: '3'}).respond(200, {name: 'a different parcel'});
+ expect($scope.parcels.length).toBe(0);
+ expect($scope.newParcel).toEqual($scope.defaults);
+ $scope.newParcel.name = 'test parcel';
+ $scope.create($scope.newParcel);
+ $httpBackend.flush();
+ expect($scope.parcels[0].name).toBe('a different parcel');
+ expect($scope.newParcel).toEqual($scope.defaults);
+ });
+
+ it('should be able to update a parcel', function() {
+ $scope.parcels = [{_id: 123, name: 'test parcel'}];
+ $httpBackend.expectPUT('/api/parcels/' + $scope.parcels[0]._id, {_id: 123, name: 'test parcel', editing: false}).respond(200, {name: 'a very different parcel'});
+ $scope.update($scope.parcels[0]);
+ $httpBackend.flush();
+ expect($scope.parcels[0].name).toBe('test parcel');
+ expect($scope.parcels[0].editing).toBe(false);
+ });
+
+ it('should be able to delete a parcel', function() {
+ $scope.parcels = [{_id: 123, name: 'test parcel'}];
+ $httpBackend.expectDELETE('/api/parcels/' + $scope.parcels[0]._id).respond(200);
+ $scope.remove($scope.parcels[0]);
+ $httpBackend.flush();
+ expect($scope.parcels.length).toBe(0);
+ });
+
+ });
+});
diff --git a/tinasharma/test/client/test_entry.js b/tinasharma/test/client/test_entry.js
new file mode 100644
index 0000000..c891bf1
--- /dev/null
+++ b/tinasharma/test/client/test_entry.js
@@ -0,0 +1 @@
+require('./parcels_controller_tests.js');