diff --git a/README.md b/README.md
index 51df08b..7fe240e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,22 @@
WebApps 3: Project
=
-Drawing webapplication
+Drawing Web Application
-
+This Application was developed for my college class "WebApps III".
+
+Features:
+-
+* Draw together with others
+* Save your drawings
+* Authentication (& sessions)
+* Custom colors
+* Custom brush size
+* Clear the Canvas
+* Home Page showing several saved drawings
+* More to come...
+
+
##### By:
Thomas Buys, 3D
\ No newline at end of file
diff --git a/client/app/auth/auth.config.js b/client/app/auth/auth.config.js
index a648710..4de2316 100644
--- a/client/app/auth/auth.config.js
+++ b/client/app/auth/auth.config.js
@@ -1,5 +1,4 @@
function AuthConfig($stateProvider, $httpProvider) {
- 'ngInject';
// Define the routes
$stateProvider
@@ -29,5 +28,6 @@ function AuthConfig($stateProvider, $httpProvider) {
});
};
+AuthConfig.$inject = ["$stateProvider", "$httpProvider"]; //Explicit annotation needed!
export default AuthConfig;
\ No newline at end of file
diff --git a/client/app/canvas/canvas.config.js b/client/app/canvas/canvas.config.js
index 61a427b..06f9d96 100644
--- a/client/app/canvas/canvas.config.js
+++ b/client/app/canvas/canvas.config.js
@@ -1,5 +1,4 @@
function CanvasConfig($stateProvider) {
- 'ngInject';
$stateProvider
.state('app.canvas', {
@@ -15,5 +14,6 @@ function CanvasConfig($stateProvider) {
});
};
+CanvasConfig.$inject = ["$stateProvider"]; //Explicit annotation needed!
export default CanvasConfig;
diff --git a/client/app/canvas/canvas.controller.js b/client/app/canvas/canvas.controller.js
index a2384d1..f995483 100644
--- a/client/app/canvas/canvas.controller.js
+++ b/client/app/canvas/canvas.controller.js
@@ -51,7 +51,7 @@ class CanvasCtrl {
this.App.canvas.onselectstart = () => {
return false;
};
- this.App.ctx.fillStyle = 'solid';
+ this.App.ctx.fillStyle = '#000000';
this.App.ctx.strokeStyle = '#000000';
this.App.ctx.lineWidth = 5;
this.App.ctx.lineCap = 'round';
diff --git a/client/app/canvas/canvas.spec.js b/client/app/canvas/canvas.spec.js
new file mode 100644
index 0000000..fa5bf97
--- /dev/null
+++ b/client/app/canvas/canvas.spec.js
@@ -0,0 +1,51 @@
+describe("Canvas Controller Test", () => {
+ describe("When I call canvas.init", () => {
+
+ beforeEach(angular.mock.module('app'));
+
+ let scope;
+ let vm;
+
+ beforeEach(inject(($controller, _$rootScope_) => {
+ scope = _$rootScope_.$new();
+ vm = $controller('CanvasCtrl', { $scope: scope });
+ }));
+
+ it('sets the brush size to 5', () => {
+ const size = 5;
+ expect(vm.App.ctx.lineWidth).toEqual(size);
+ expect(vm.ownBrushSize).toEqual(size);
+ });
+
+ it('sets the fillStyle to solid', () => {
+ const lineCap = "round";
+ expect(vm.App.ctx.lineCap).toEqual(lineCap);
+ });
+
+ it('changes brush size correctly when method is called', () => {
+ const initialSize = 5;
+ const newSize = 85;
+ expect(vm.App.ctx.lineWidth).toEqual(initialSize);
+ expect(vm.ownBrushSize).toEqual(initialSize);
+ vm.App.changeBrushSize(85);
+ expect(vm.App.ctx.lineWidth).toEqual(newSize);
+ expect(vm.ownBrushSize).toEqual(newSize);
+ });
+
+ it('sets the alert boolean to false initially', () => {
+ const bool = false;
+ expect(scope.showAlert).toEqual(bool);
+ });
+
+ it('changes brush color correctly when method is called', () => {
+ const initialColor = "#000000";
+ const newColor = "#111111";
+ expect(vm.App.ctx.strokeStyle).toEqual(initialColor);
+ expect(vm.ownColor).toEqual(initialColor);
+ scope.submitCustomColor("#111111");
+ expect(vm.App.ctx.strokeStyle).toEqual(newColor);
+ expect(vm.ownColor).toEqual(newColor);
+ });
+
+ });
+});
\ No newline at end of file
diff --git a/client/app/config/app.config.js b/client/app/config/app.config.js
index 0ad0ea2..7579623 100644
--- a/client/app/config/app.config.js
+++ b/client/app/config/app.config.js
@@ -1,7 +1,6 @@
import authInterceptor from './auth.interceptor';
function AppConfig($httpProvider, $stateProvider, $locationProvider, $urlRouterProvider) {
- 'ngInject';
$httpProvider.interceptors.push(authInterceptor);
@@ -25,5 +24,6 @@ function AppConfig($httpProvider, $stateProvider, $locationProvider, $urlRouterP
$urlRouterProvider.otherwise('/');
}
+AppConfig.$inject = ["$httpProvider", "$stateProvider", "$locationProvider", "$urlRouterProvider"]; //Explicit annotation needed!
export default AppConfig;
diff --git a/client/app/config/app.run.js b/client/app/config/app.run.js
index 9e711f4..1c22f32 100644
--- a/client/app/config/app.run.js
+++ b/client/app/config/app.run.js
@@ -17,5 +17,6 @@ function AppRun(AppConstants, $rootScope) {
};
}
+AppRun.$inject = ["AppConstants", "$rootScope"]; //Explicit annotation needed!
export default AppRun;
diff --git a/client/app/config/app.templates.js b/client/app/config/app.templates.js
index 342c03f..c807e50 100644
--- a/client/app/config/app.templates.js
+++ b/client/app/config/app.templates.js
@@ -1,8 +1,8 @@
-angular.module('templates', []).run(['$templateCache', function($templateCache) {$templateCache.put('canvas/canvas.html','
\r\n\t
\r\n\t\t- \r\n\t\t\t\r\n\t\t\t\tHome\r\n\t\t\t\r\n\t\t
\r\n\t\t\r\n\t\t\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t
\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t
\r\n\t\t\r\n\t\t\t\r\n\t\t\t{{textTitle}} {{textAlert}}\r\n\t\t
\r\n\t
\r\n
\r\n\t\r\n\r\n\r\n\t
\r\n\t\r\n\t\r\n
\r\n\r\n');
-$templateCache.put('auth/auth.html','');
+angular.module('templates', []).run(['$templateCache', function($templateCache) {$templateCache.put('auth/auth.html','');
$templateCache.put('components/list-errors.html','');
+$templateCache.put('canvas/canvas.html','\r\n\t
\r\n\t\t- \r\n\t\t\t\r\n\t\t\t\tHome\r\n\t\t\t\r\n\t\t
\r\n\t\t\r\n\t\t\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t
\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t
\r\n\t\t\r\n\t\t\t\r\n\t\t\t{{textTitle}} {{textAlert}}\r\n\t\t
\r\n\t
\r\n
\r\n\t\r\n\r\n\r\n\t
\r\n\t\r\n\t\r\n
\r\n\r\n');
+$templateCache.put('home/home.html','\r\n\r\n\t
\r\n\t\t
\r\n\r\n\t\t - \r\n\t\t\t\r\n\t\t\t Canvas\r\n\t\t\t\r\n\t\t
\r\n\t\t \r\n\t\t WebApps 3 Drawing Application
\r\n\r\n\t\t \r\n\t\t \r\n\t\t \r\n\r\n\t\t
\r\n\t
\r\n\t\r\n\t
\r\n\t\t
Welcome to the home page of this Drawing Application.
\r\n\t\t
This website allows you to draw alone or with other people. You can also name your drawing and save it, it will then display here on the home page.
\r\n\t\t
Below you can see a list of drawings that were already saved by other people.
\r\n\t\t
This website was developed by Thomas Buys.
\r\n\t
\r\n\t\r\n\t
\r\n\t\r\n\t
\r\n\r\n
\r\n');
$templateCache.put('layout/app-view.html','');
$templateCache.put('layout/footer.html','');
$templateCache.put('layout/header.html','\r\n\t\r\n\tEvil Drawing\r\n
');
-$templateCache.put('layout/sidebar.html','');
-$templateCache.put('home/home.html','\r\n\r\n\t
\r\n\t\t
\r\n\r\n\t\t - \r\n\t\t\t\r\n\t\t\t Canvas\r\n\t\t\t\r\n\t\t
\r\n\t\t \r\n\t\t WebApps 3 Drawing Application
\r\n\r\n\t\t \r\n\t\t \r\n\t\t \r\n\r\n\t\t
\r\n\t
\r\n\t\r\n\t
\r\n\t\t
Welcome to the home page of this Drawing Application.
\r\n\t\t
This website allows you to draw alone or with other people. You can also name your drawing and save it, it will then display here on the home page.
\r\n\t\t
Below you can see a list of drawings that were already saved by other people.
\r\n\t\t
This website was developed by Thomas Buys.
\r\n\t
\r\n\t\r\n\t
\r\n\t\r\n\t
\r\n\r\n
\r\n');}]);
\ No newline at end of file
+$templateCache.put('layout/sidebar.html','');}]);
\ No newline at end of file
diff --git a/client/app/config/auth.interceptor.js b/client/app/config/auth.interceptor.js
index 9ec33ed..003911e 100644
--- a/client/app/config/auth.interceptor.js
+++ b/client/app/config/auth.interceptor.js
@@ -17,5 +17,6 @@ function authInterceptor(JWT, AppConstants, $window, $q) {
}
}
}
+authInterceptor.$inject = ["JWT", "AppConstants", "$window", "$q"]; //Explicit annotation needed!
export default authInterceptor;
\ No newline at end of file
diff --git a/client/app/home/home.config.js b/client/app/home/home.config.js
index ede6de8..55729bf 100644
--- a/client/app/home/home.config.js
+++ b/client/app/home/home.config.js
@@ -1,5 +1,4 @@
function HomeConfig($stateProvider) {
- 'ngInject';
$stateProvider
.state('app.home', {
@@ -11,5 +10,6 @@ function HomeConfig($stateProvider) {
});
};
+HomeConfig.$inject = ["$stateProvider"]; //Explicit annotation needed!
export default HomeConfig;
diff --git a/client/app/services/jwt.service.js b/client/app/services/jwt.service.js
index a6ac405..4b5c0b3 100644
--- a/client/app/services/jwt.service.js
+++ b/client/app/services/jwt.service.js
@@ -17,4 +17,5 @@ export default class JWT {
destroy() {
this._$window.localStorage.removeItem(this._AppConstants.jwtKey);
}
-}
\ No newline at end of file
+}
+JWT.$inject = ["AppConstants", "$window"]; //Explicit annotation needed!
\ No newline at end of file
diff --git a/karma.conf.babel.js b/karma.conf.babel.js
new file mode 100644
index 0000000..93242d0
--- /dev/null
+++ b/karma.conf.babel.js
@@ -0,0 +1,94 @@
+// Karma configuration
+// Generated on Tue Dec 06 2016 21:41:03 GMT+0100 (Romance Standard Time)
+
+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: [
+ 'https://code.jquery.com/jquery-3.1.1.js',
+ 'node_modules/angular/angular.js',
+ 'node_modules/angular-mocks/angular-mocks.js',
+ 'node_modules/angular-ui-router/release/angular-ui-router.js',
+ 'node_modules/angular-material/angular-material.js',
+ 'node_modules/angular-animate/angular-animate.js',
+ 'node_modules/angular-aria/angular-aria.js',
+ 'http://localhost:9876/socket.io/socket.io.js',
+ 'client/app/app.js',
+ { pattern: 'test-context.js', watched: false }
+ ],
+
+
+ // 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: {
+ 'client/app/app.js': ['webpack'],
+ 'test-context.js': ['webpack']
+ },
+ webpack: {
+ module: {
+ loaders: [
+ { test: /\.js/, exclude: /node_modules/, loader: 'babel-loader' }
+ ]
+ },
+ node: {
+ fs: 'empty'
+ },
+ watch: true
+ },
+ webpackServer: {
+ noInfo: true
+ },
+
+
+ // 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: true,
+
+
+ // start these browsers
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+ browsers: ['Chrome'],
+
+
+ // Continuous Integration mode
+ // if true, Karma captures browsers, runs the tests and exits
+ singleRun: false,
+
+ // Concurrency level
+ // how many browser should be started simultaneous
+ concurrency: Infinity
+ })
+}
diff --git a/package.json b/package.json
index f6efa4d..8bf95de 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
},
"homepage": "https://github.com/gevalo1/WebApps3#readme",
"devDependencies": {
+ "angular-mocks": "^1.5.8",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
@@ -45,6 +46,13 @@
"gulp-notify": "^2.2.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^2.0.0",
+ "jasmine": "^2.5.2",
+ "jasmine-core": "^2.5.2",
+ "karma": "^1.3.0",
+ "karma-babel-preprocessor": "^6.0.1",
+ "karma-chrome-launcher": "^2.0.0",
+ "karma-jasmine": "^1.0.2",
+ "karma-webpack": "^1.8.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
@@ -57,13 +65,13 @@
"body-parser": "1.15.2",
"cookie-parser": "1.4.3",
"cors": "^2.8.1",
- "ejs": "2.5.2",
+ "ejs": "2.5.5",
"express": "4.14.0",
"gulp": "^3.9.1",
"jsonwebtoken": "^7.1.9",
"mongoose": "^4.6.6",
"morgan": "1.7.0",
- "serve-favicon": "2.3.0",
+ "serve-favicon": "2.3.2",
"socket.io": "^1.5.1"
}
}
diff --git a/spec/run.js b/spec/run.js
new file mode 100644
index 0000000..9740a8d
--- /dev/null
+++ b/spec/run.js
@@ -0,0 +1,5 @@
+import Jasmine from 'jasmine'
+
+var jasmine = new Jasmine()
+jasmine.loadConfigFile('spec/support/jasmine.json')
+jasmine.execute()
\ No newline at end of file
diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json
new file mode 100644
index 0000000..1a4529c
--- /dev/null
+++ b/spec/support/jasmine.json
@@ -0,0 +1,11 @@
+{
+ "spec_dir": "spec",
+ "spec_files": [
+ "client/app/**/*[sS]pec.js"
+ ],
+ "helpers": [
+ "helpers/**/*.js"
+ ],
+ "stopSpecOnExpectationFailure": false,
+ "random": false
+}
diff --git a/test-context.js b/test-context.js
new file mode 100644
index 0000000..8684560
--- /dev/null
+++ b/test-context.js
@@ -0,0 +1,2 @@
+var context = require.context('./client/app', true, /spec\.js$/);
+context.keys().forEach(context);
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
index 4c6dc17..58666c1 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -3,7 +3,7 @@ var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
- devtool: 'source-map',
+ devtool: 'inline-source-map',
entry: {},
module: {
loaders: [