From 65132a492917823fd56c3937e9c03e96df73a2ea Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 13:59:11 -0700 Subject: [PATCH 01/13] general scaffold created --- .babelrc | 0 .gitignore | 118 ++++++++++++++++++++++++++++++++++++++++++++++ karma.config.js | 40 ++++++++++++++++ package.json | 55 +++++++++++++++++++++ webpack.config.js | 46 ++++++++++++++++++ 5 files changed, 259 insertions(+) create mode 100644 .babelrc create mode 100644 .gitignore create mode 100644 karma.config.js create mode 100644 package.json create mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43eb113 --- /dev/null +++ b/.gitignore @@ -0,0 +1,118 @@ +# Created by https://www.gitignore.io/api/osx,windows,node + +build/ + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +### +.env + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/osx,windows,node diff --git a/karma.config.js b/karma.config.js new file mode 100644 index 0000000..14d24df --- /dev/null +++ b/karma.config.js @@ -0,0 +1,40 @@ +const webpack = require('./webpack.config.js'); +delete webpack.entry; + +module.exports = function(config) { + config.set({ + webpack, + basePath: '', + + frameworks: ['jasmine'], + + files: [ + 'app/entry.js', + 'test/**/*-test.js', + 'node_modules/angular-mocks/angular-mocks.js' + ], + + exclude: [], + + preprocessors: { + 'test/**/*-test.js': ['webpack'], + 'app/entry.js': ['webpack'] + }, + + reporters: ['mocha'], + + port: 9876, + + colors: true, + + logLevel: config.LOG_INFO, + + autoWatch: true, + + browsers: ['Chrome'], + + singleRun: false, + + concurrency: Infinity + }) +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..61aa515 --- /dev/null +++ b/package.json @@ -0,0 +1,55 @@ +{ + "name": "31-testing_components", + "version": "1.0.0", + "description": "![cf](https://i.imgur.com/7v5ASc8.png) Lab 31 - Testing Components ======", + "main": "karma.config.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/shivprogrammer/31-testing_components.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/shivprogrammer/31-testing_components/issues" + }, + "homepage": "https://github.com/shivprogrammer/31-testing_components#readme", + "dependencies": { + "angular": "^1.6.4", + "angular-animate": "^1.6.4", + "angular-mocks": "^1.6.4", + "angular-route": "^1.6.4", + "angular-touch": "^1.6.4", + "angular-ui-router": "^0.4.2", + "babel-core": "^6.24.0", + "babel-loader": "^6.4.1", + "babel-preset-es2015": "^6.24.0", + "camelcase": "^4.1.0", + "clean-webpack-plugin": "^0.1.16", + "css-loader": "^0.28.0", + "dotenv": "^4.0.0", + "extract-text-webpack-plugin": "^2.1.0", + "file-loader": "^0.11.1", + "html-loader": "^0.4.5", + "html-webpack-plugin": "^2.28.0", + "jasmine-core": "^2.5.2", + "karma": "^1.6.0", + "karma-chrome-launcher": "^2.0.0", + "karma-jasmine": "^1.1.0", + "karma-mocha-reporter": "^2.2.3", + "karma-webpack": "^2.0.3", + "ng-file-upload": "^12.2.13", + "node-sass": "^4.5.2", + "pascalcase": "^0.1.1", + "resolve-url-loader": "^2.0.2", + "sass-loader": "^6.0.3", + "style-loader": "^0.16.1", + "ui-router": "^1.0.0-alpha.3", + "url-loader": "^0.5.8", + "webpack": "^2.3.3", + "webpack-dev-server": "^2.4.2" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..a766cd1 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,46 @@ +'use strict'; + +const dotenv = require('dotenv'); +const webpack = require('webpack'); +const HTMLPlugin = require('html-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); + +const production = process.env.NODE_ENV = 'production'; + +dotenv.load(); + +module.exports = { + devtool: 'eval', + entry: `${__dirname}/app/entry.js`, + output: { + filename: 'bundle.js', + path: `${__dirname}/build` + }, + plugins: [ + new HTMLPlugin({ + template: `${__dirname}/app/entry.js` + }), + new ExtractTextPlugin('bundle.css'), + new webpack.DefinePlugin({ + __API_URL__: JSON.stringify(process.env.API_URL), + __DEBUG__: JSON.stringify(!production) + }) + ], + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + loaders: 'babel-loader' + }, + { + test: /\.html$/, + loader: 'html-loader' + }, + { + test: /\.scss$/, + loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) + } + ] + } +} From 3bd81e76e0d8817c8b507c44526c2253f32950f1 Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 15:25:29 -0700 Subject: [PATCH 02/13] edit gallery component test file added, although untested --- test/edit-gallery-component-test.js | 63 +++++++++++++++++++++++++++++ test/gallery-item-component-test.js | 0 2 files changed, 63 insertions(+) create mode 100644 test/edit-gallery-component-test.js create mode 100644 test/gallery-item-component-test.js diff --git a/test/edit-gallery-component-test.js b/test/edit-gallery-component-test.js new file mode 100644 index 0000000..f2c4f21 --- /dev/null +++ b/test/edit-gallery-component-test.js @@ -0,0 +1,63 @@ +'use strict'; + +describe('WE IN THE GALLERY COMPONENT TEST BABY BAYYBAYY', function() => { + + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, $componentController, $httpBackend, authService) => { + this.$rootScope = $rootScope; + this.$componentController = $componentController; + this.$httpBackend = $httpBackend; + this.authService = authService; + }) + }); + + it('SHOULD BIND THAT SEXY SONOFABISH', () => { + let mockBindings = { + gallery: { + name: 'TO THE WINDOWWWWWW', + desc: 'TO THE WAAAAALLLLL' + } + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + expect(editGalleryCtrl.gallery.name).toEqual(mockBindings.gallery.name); + expect(editGalleryCtrl.gallery.desc).toEqual(mockBindings.gallery.desc); + + this.$rootScope.$apply(); + }) + + describe('editGalleryCtrl.updateGallery()', () => { + it('happy tests for a newly updated gallery mayne', () => { + let url = 'http://localhost:8000/api/gallery/12345', + let headers = { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: 'Bearer this token' + }; + + this.$httpBackend.expectPUT(url, { + _id: '12345', + name: 'DIS A NEW NAME', + desc: 'DIS A NEW DESCRIPTION' + }, headers).respond(200); + + let mockBindings = { + gallery: { + _id: '12345', + name: 'DIS A NEW NAME', + desc: 'DIS A NEW DESCRIPTION' + }, + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + editGalleryCtrl.gallery.name = 'DIS A NEW NAME'; + editGalleryCtrl.gallery.desc = 'DIS A NEW DESCRIPTION'; + editGalleryCtrl.updateGallery(); + // TODO: AYYYY THROW SOME TESTS UP IN THIS BISH + + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }) + }) +}) diff --git a/test/gallery-item-component-test.js b/test/gallery-item-component-test.js new file mode 100644 index 0000000..e69de29 From 9865017f7c087c5b05446d49c90c978a427cc3e0 Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 16:00:46 -0700 Subject: [PATCH 03/13] added in the entry file --- app/entry.js | 40 ++++++++++++++++++++++++++++++++++++++++ app/index.html | 0 app/scss/main.scss | 0 3 files changed, 40 insertions(+) create mode 100644 app/entry.js create mode 100644 app/index.html create mode 100644 app/scss/main.scss diff --git a/app/entry.js b/app/entry.js new file mode 100644 index 0000000..ed7c823 --- /dev/null +++ b/app/entry.js @@ -0,0 +1,40 @@ +'use strict'; + +require('./scss/main.scss'); + +const path = require('path'); +const angular = require('angular'); +const camelcase = require('camelcase'); +const pascalcase = require('pascalcase'); +const uiRouter = require('angular-ui-router'); +const ngTouch = require('angular-touch'); +const ngAnimate = require('angular-animate'); +const ngFileUpload = require('ng-file-upload'); + +const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter, ngFileUpload]) + +let context = require.context('./config/', true, /\.js$/); +context.keys().forEach( path => { + cfgram.config(context(path)); +}); + +context = require.context('./view/', true, /\.js$/); +context.keys().forEach( key => { + let name = pascalcase(path.basename(key, '.js')); + let module = context(key); + cfgram.controller(name, module); +}); + +context = require.context('./service/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.controller(name, module); +}); + +context = require.context('./component/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.component(name, module); +}); diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..e69de29 diff --git a/app/scss/main.scss b/app/scss/main.scss new file mode 100644 index 0000000..e69de29 From f47bf4ccb365b4bef4dcb9e1a1cbf884b4d35993 Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 16:05:14 -0700 Subject: [PATCH 04/13] index.html file has been inserted --- app/index.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/index.html b/app/index.html index e69de29..6fc6505 100644 --- a/app/index.html +++ b/app/index.html @@ -0,0 +1,19 @@ + + + + + + cfgram + + +
+ +
+ +
+ +
+ +
+ + From 7a1234004839d114d8c5a1588a2a0ff3321c0b2b Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 17:00:08 -0700 Subject: [PATCH 05/13] muscled through the auth service file --- app/service/auth-service.js | 88 ++++++++++++++++++++++++++++++++++ app/service/gallery-service.js | 0 app/service/pic-service.js | 0 3 files changed, 88 insertions(+) create mode 100644 app/service/auth-service.js create mode 100644 app/service/gallery-service.js create mode 100644 app/service/pic-service.js diff --git a/app/service/auth-service.js b/app/service/auth-service.js new file mode 100644 index 0000000..b7aa361 --- /dev/null +++ b/app/service/auth-service.js @@ -0,0 +1,88 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', '$window', authService]; + +function authService($q, $log, $http, $window) { + $log.debug('authService'); + + let service = {}; + let token = null; + + function setToken(_token) { + $log.debug('authService.setToken'); + + if (_token) { + return $q.reject(new Error('no token')); + }; + + $window.localStorage.setItem('token', _token); + token = _token; + return $q.resolve(token); + } + + service.getToken = function() { + $log.debug(authService.getToken); + if (token) { + return $q.resolve(token); + }; + + token = $window.localStorage.getItem('token'); + if (token) return $q.resolve(token); + return $q.reject(new Error('theres no token bruh')); + }; + + service.logout = function() { + $log.debug(authService.getToken); + + $window.localStorage.removeItem('token'); + token = null; + return $q.resolve(); + }; + + service.signup = function() { + $log.debug('authService.signup'); + + let url = `${__API_URL__}/api/signup`; + let config = { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json' + } + }; + + return $http.post(url, user, config) + .then( res => { + $log.log('success', res.data); + return setToken(res.data); + }) + .catch( err => { + $log.error('failure', err.message); + return $q.reject(err); + }) + }; + + service.login = function(user) { + $log.debug('authService.login') + + let url = `${__API_URL__}/api/login`; + let base64 = $window.btoa(`${user.username}:${user.password}`); + let config = { + headers: { + Accept: 'application/json', + Authorization: `Basic ${base64}` + } + }; + + return $http.get(url, config) + .then( res => { + $log.log('success', res.data); + return setToken(res.data); + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + return service; +} diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js new file mode 100644 index 0000000..e69de29 diff --git a/app/service/pic-service.js b/app/service/pic-service.js new file mode 100644 index 0000000..e69de29 From c0333462037e32c9af2adbfc409dec69f4bd336c Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 17:53:51 -0700 Subject: [PATCH 06/13] digested the gallery-service.js file successfully --- app/service/gallery-service.js | 143 +++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js index e69de29..edebcd1 100644 --- a/app/service/gallery-service.js +++ b/app/service/gallery-service.js @@ -0,0 +1,143 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'authService', galleryService]; + +function galleyService($q, $log, $http, authService, galleryService) { + $log.debug('galleryService'); + + let service = {}; + service.galleries = []; + + service.createGallery = function(gallery) { + $log.debug('galleryService.createGallery'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery`; + let config = { + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + }; + + return $http.post(url, gallery, config); + }) + .then( res => { + $log.log('gallery created'); + let gallery = res.data; + service.galleries.unshift(galllery); + return gallery; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }) + }; + + service.deleteGalleries = function(galleryID, galleryData) { + $log.debug(galleryService.deleteGalleries); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + } + } + }) + }; + + service.fetchGalleries = function() { + $log.debug('galleryService.fetchGalleries'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery` + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + } + }; + + return $http.get(url, config); + }) + .then( res => { + $log.log('we got dem galleries baby'); + service.galleries = res.data; + return $q.resolve(res.data); + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }) + } + + service.updateGallery = function(galleryID, galleryData) { + $log.debug('galleryService.updateGallery') + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + 'Content-Type': 'application/json', + } + } + + return $http.put(url, galleryData, config); + }) + .then( res => { + for (let i = 0; i < service.galleries.length; i++) { + let current = service.galleries[i]; + if (current._id === galleryID) { + service.galleries[i] = res.data; + break; + } + } + + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }) + } + + service.deleteGallery = function(galleryID) { + $log.debug('galleryService.deleteGallery'); + + return authService.getToken() + .then (token => { + let url = `${__API_URL__}/api/gallery/${galleryID}` + let config = { + headers: { + Authorization: `Bearer ${token}` + } + } + + return $http.delete(url, config); + }) + .then( res => { + for (let i = 0; i < service.galleries.length; i++) { + let current = service.galleries[i]; + if(current._id === galleryID) { + service.galleries.splice(i, 1); + break; + } + } + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }) + }; + + return service; +}; From 898515561804a6c7fd56ff47614c256b8afcd52d Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 18:15:25 -0700 Subject: [PATCH 07/13] hit that pic service file --- app/service/auth-service.js | 2 +- app/service/pic-service.js | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/app/service/auth-service.js b/app/service/auth-service.js index b7aa361..354170e 100644 --- a/app/service/auth-service.js +++ b/app/service/auth-service.js @@ -64,7 +64,7 @@ function authService($q, $log, $http, $window) { service.login = function(user) { $log.debug('authService.login') - let url = `${__API_URL__}/api/login`; + let url = `${__API_URL__}/api/log\in`; let base64 = $window.btoa(`${user.username}:${user.password}`); let config = { headers: { diff --git a/app/service/pic-service.js b/app/service/pic-service.js index e69de29..5ddc280 100644 --- a/app/service/pic-service.js +++ b/app/service/pic-service.js @@ -0,0 +1,43 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'Upload', 'authService', picService]; + +function picService($q, $log, $http, Upload, authService) { + $log.debug('picService'); + + let service = {}; + + service.uploadGalleryPic = function(galleryData, picData) { + $log.debug('picService.uploadGalleryPic'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic`; + let headers = { + Authorization: `Bearer ${token}`, + Accept: 'application/json' + }; + + return Upload.upload({ + url, + headers, + method: 'POST', + data: { + name: picData.name, + desc: picData.desc, + file: picData.file + } + }); + }) + .then( res => { + galleryData.pics.unshift(res.data): + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }) + }; + + return service; +} From a6b6b98e750686ce9ff58e9871757c7afd6f6bdd Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 18:29:44 -0700 Subject: [PATCH 08/13] got the config files --- app/config/log-config.js | 7 +++++++ app/config/router-config.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 app/config/log-config.js create mode 100644 app/config/router-config.js diff --git a/app/config/log-config.js b/app/config/log-config.js new file mode 100644 index 0000000..c84d58c --- /dev/null +++ b/app/config/log-config.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = ['$logProvider', logConfig]; + +function logConfig($logProvider) { + $logProvider.debugEnabled(__DEBUG__); +}; diff --git a/app/config/router-config.js b/app/config/router-config.js new file mode 100644 index 0000000..a1cea0f --- /dev/null +++ b/app/config/router-config.js @@ -0,0 +1,31 @@ +'use strict'; + +module.exports = ['$stateProvider', '$urlRouterProvider', routerConfig]; + +function routerConfig($stateProvider, $urlRouterProvider) { + $urlRouterProvider.when('', '/join#signup'); + $urlRouterProvider.when('/', '/join#signup'); + $urlRouterProvider.when('/signup', '/join#signup'); + $urlRouterProvider.when('login', '/join#login'); + + let states = [ + { + name: 'home', + url: '/home', + template: require('../view/home/home.html'), + controller: 'HomeController', + controllerAs: 'homeCtrl' + }, + { + name: 'landing', + url: '/join', + template: require('../view/home/landing.html'), + Controller: 'LandingController', + ControllerAs: 'landingCtrl' + } + ]; + + states.forEach( state => { + $stateProvider.state(state); + }) +} From 1f33f4e69912c2ace802240898eac484813ced1c Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 19:13:26 -0700 Subject: [PATCH 09/13] got the navbar.html and navbar.js files --- app/component/navbar/_navbar.scss | 0 app/component/navbar/navbar.html | 10 +++++++ app/component/navbar/navbar.js | 46 +++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 app/component/navbar/_navbar.scss create mode 100644 app/component/navbar/navbar.html create mode 100644 app/component/navbar/navbar.js diff --git a/app/component/navbar/_navbar.scss b/app/component/navbar/_navbar.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/component/navbar/navbar.html b/app/component/navbar/navbar.html new file mode 100644 index 0000000..7457559 --- /dev/null +++ b/app/component/navbar/navbar.html @@ -0,0 +1,10 @@ + diff --git a/app/component/navbar/navbar.js b/app/component/navbar/navbar.js new file mode 100644 index 0000000..2a12f14 --- /dev/null +++ b/app/component/navbar/navbar.js @@ -0,0 +1,46 @@ +'use strict'; + +require('./navbar.scss'); + +module.exports = { + template: require('./navbar.html'); + controller: ['$log', '$location', '$rootScope', 'authService', NavbarController]; + controllerAs: 'navbarCtrl' +}; + +function NavbarController($log, $location, $rootScope, authService) { + $log.debug('NavbarController'); + + this.checkPath = function() { + $log.debug('NavbarController.checkPath'); + + let path = $location.path(); + if (path === '/join') { + this.hidebuttons = true; + } + + if (path !== '/join') { + this.hideButtons = false; + authService.getToken() + .catch( err => { + $location.url('/join#login'); + }) + } + }; + + this.checkPath(); + + $rootScope.$on('$locationChangeSuccess', () => { + this.checkPath(); + }) + + this.logout = function() { + $log.log('navbarCtrl.logout'); + + this.hidebuttons = true; + authService.logout() + .then( () => { + $location.url('/'); + }) + }; +}; From 1b79ad72547aa28fb416bfa4dc4aceb70ab5a3c2 Mon Sep 17 00:00:00 2001 From: Shiv Date: Wed, 5 Apr 2017 19:26:47 -0700 Subject: [PATCH 10/13] create gallery component has been created, but without styling --- .../create-gallery/_create-gallery.scss | 0 .../create-gallery/create-gallery.html | 27 +++++++++++++++++++ .../gallery/create-gallery/create-gallery.js | 23 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 app/component/gallery/create-gallery/_create-gallery.scss create mode 100644 app/component/gallery/create-gallery/create-gallery.html create mode 100644 app/component/gallery/create-gallery/create-gallery.js diff --git a/app/component/gallery/create-gallery/_create-gallery.scss b/app/component/gallery/create-gallery/_create-gallery.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/component/gallery/create-gallery/create-gallery.html b/app/component/gallery/create-gallery/create-gallery.html new file mode 100644 index 0000000..f182edc --- /dev/null +++ b/app/component/gallery/create-gallery/create-gallery.html @@ -0,0 +1,27 @@ + diff --git a/app/component/gallery/create-gallery/create-gallery.js b/app/component/gallery/create-gallery/create-gallery.js new file mode 100644 index 0000000..2666595 --- /dev/null +++ b/app/component/gallery/create-gallery/create-gallery.js @@ -0,0 +1,23 @@ +'use strict'; + +require('./_create-gallery.scss'); + +module.exports = { + template: require('./create-gallery.html'), + controller: ['$log', 'galleryService', CreateGalleryController], + controllerAs: 'createGalleryCtrl' +}; + +function CreateGalleryController($log, galleryService) { + $log.debug('CreateGalleryController'); + + this.gallery = {}; + + this.createGallery = function() { + galleryService.createGallery(this.gallery) + .then( () => { + this.gallery.name = null; + this.gallery.desc = null; + }) + } +}; From 39ea6b90a69f0667a6776ba6eced51d467a63fa6 Mon Sep 17 00:00:00 2001 From: Shiv Date: Thu, 6 Apr 2017 06:13:07 -0700 Subject: [PATCH 11/13] dat gallery item component test doe --- app/assets/cf-logo.png | Bin 0 -> 6821 bytes .../gallery/edit-gallery/_edit-gallery.scss | 0 .../gallery/edit-gallery/edit-gallery.html | 19 ++++++ .../gallery/edit-gallery/edit-gallery.js | 20 ++++++ .../gallery/gallery-item/_gallery-item.scss | 0 .../gallery/gallery-item/gallery-item.html | 19 ++++++ .../gallery/gallery-item/gallery-item.js | 22 ++++++ app/view/landing/_landing.scss | 0 app/view/landing/landing-controller.js | 10 +++ app/view/landing/landing.html | 21 ++++++ package.json | 8 ++- test/auth-service-test.js | 31 +++++++++ test/gallery-item-component-test.js | 63 ++++++++++++++++++ 13 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 app/assets/cf-logo.png create mode 100644 app/component/gallery/edit-gallery/_edit-gallery.scss create mode 100644 app/component/gallery/edit-gallery/edit-gallery.html create mode 100644 app/component/gallery/edit-gallery/edit-gallery.js create mode 100644 app/component/gallery/gallery-item/_gallery-item.scss create mode 100644 app/component/gallery/gallery-item/gallery-item.html create mode 100644 app/component/gallery/gallery-item/gallery-item.js create mode 100644 app/view/landing/_landing.scss create mode 100644 app/view/landing/landing-controller.js create mode 100644 app/view/landing/landing.html create mode 100644 test/auth-service-test.js diff --git a/app/assets/cf-logo.png b/app/assets/cf-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..38a23b2d1d0dc6944768b2f98fae55197b0155b7 GIT binary patch literal 6821 zcmdT}c{r5c+aF9COBpFtb|G1Y?2Iv%LSnK+_H0R(!C1yJwk$^9=iK*sc*8{h1nW6g003~p z&_K_OULODe3}6s5y_Ifr_7c4Ux@#M20{|5%YzI!q=+8nf24=irftd@KuLEf`fx)gB4_v{_YTYH8nMe z+-1n+%QAEc8B~Z*fD>BA2POJ9$UkxP+)yt59=-t{NFSj;xK7T%>-yWy z0FOKW?#T!B54Y$JLjG_d^0IP}|4ohV?7!^$4=uEl@83#)dG&W^&_7V>2!9VZy19Rh zg2_Ywg8vWNzm0>^(baYR-JAlD{uW527fk!lSPL0?JGr}=xjDIpKq3EA;vdRT$RBtA zoBMx{?O#;-;KEqxn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|i}Cx?_9IGOe(% zP^qtVAy5J+7_B9~HK1F#Lgm@&E%n@$@7lEU504>%kvaRtKFd|{bD?` zOUfHHL#fp=7uNj1;fzy=TPrV(S5MGmBTCZn1hi8{#iX8ZMNefPSF=1xB>}~q% zPQo6ajJ^uji6u3Z9Y+H@IEtj8@lc#<`5DOFSK9YF;8HHxy4mkXC!lS|Wb}g|JKjAQ zug`>5#)V#QA|Jj!m3HUFuhe;AX7uV;X=vS!E+z56+;{f}{}2)12IkVIUai-Aw1V)UfqmL^BSm^`gZ*w@jt?jQV6pnEEiB zqW;@|;L_4Bb9Som7HTnx2Ed>9F9zYRI}|kMRqli9UdEH0E&<655ce<3!IY71=IOu# zmO1&>LCqqS;b$l4X%+s$3nxi0i@Ml%AC~i%Z*uIO<4^N5oyb=<2RW2_)}8Ha`(1;a z-r#ULd2z1qxUX+Z-^RuU$m#v$Zic@i&@oZMlltU4W~{?BJiJtEW(q6#>ES~6H~5SU tDE(?whoeo-4M8ydROtV>6aWv8`?gQapd|}F{5cFVykeqPrgJ;yzW_S-o{9hf literal 0 HcmV?d00001 diff --git a/app/component/gallery/edit-gallery/_edit-gallery.scss b/app/component/gallery/edit-gallery/_edit-gallery.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/component/gallery/edit-gallery/edit-gallery.html b/app/component/gallery/edit-gallery/edit-gallery.html new file mode 100644 index 0000000..e839886 --- /dev/null +++ b/app/component/gallery/edit-gallery/edit-gallery.html @@ -0,0 +1,19 @@ +
+ +
diff --git a/app/component/gallery/edit-gallery/edit-gallery.js b/app/component/gallery/edit-gallery/edit-gallery.js new file mode 100644 index 0000000..006678b --- /dev/null +++ b/app/component/gallery/edit-gallery/edit-gallery.js @@ -0,0 +1,20 @@ +'use strict'; + +require('./_edit-gallery.scss'); + +module.exports = { + template: require('./edit-gallery.html'), + controller: ['$log', 'galleryService', EditGalleryController]; + controllerAs: 'editGalleryCtrl', + bindings: { + gallery: '<' + } +}; + +function EditGalleryController($log, galleryService) { + $log.debug('EditGalleryController'); + + this.updateGallery = function() { + galleryService.updateGallery(this.gallery._id, this.gallery); + } +} diff --git a/app/component/gallery/gallery-item/_gallery-item.scss b/app/component/gallery/gallery-item/_gallery-item.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/component/gallery/gallery-item/gallery-item.html b/app/component/gallery/gallery-item/gallery-item.html new file mode 100644 index 0000000..3be8f9c --- /dev/null +++ b/app/component/gallery/gallery-item/gallery-item.html @@ -0,0 +1,19 @@ + +
  • + edit + delete +
  • diff --git a/app/component/gallery/gallery-item/gallery-item.js b/app/component/gallery/gallery-item/gallery-item.js new file mode 100644 index 0000000..9236398 --- /dev/null +++ b/app/component/gallery/gallery-item/gallery-item.js @@ -0,0 +1,22 @@ +'use strict'; + +require('./_gallery-item.scss'); + +module.exports = { + template: require('./gallery-item.html'), + controller: ['$log', 'galleryService', GalleryItemController], + controllerAs: 'galleryItemCtrl', + bindings: { + gallery: '<' + } +}; + +function GalleryItemController($log, galleryService) { + $log.debug('GalleryItemController'); + + this.showEditGallery = false; + + this.deleteGallery = function() { + galleryService.deleteGallery(this.gallery._id); + } +}; diff --git a/app/view/landing/_landing.scss b/app/view/landing/_landing.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/view/landing/landing-controller.js b/app/view/landing/landing-controller.js new file mode 100644 index 0000000..2fcf2d2 --- /dev/null +++ b/app/view/landing/landing-controller.js @@ -0,0 +1,10 @@ +'use strict'; + +require('./_landing.scss'); + +module.exports = ['$log', '$location', '$rootScope', 'authService', LandingController]; + +function LandingController($log, $location, $rootScope, authService) { + let url = $location.url(); + this.showSignup = url === '/join#signup' || url === '/join'; +} diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html new file mode 100644 index 0000000..d5a9c89 --- /dev/null +++ b/app/view/landing/landing.html @@ -0,0 +1,21 @@ +
    +
    +
    + +
    +

    AY MAN YOU ALREADY PART OF THE LANDING SPOT?

    + + sign in right hurr. + +
    +
    +
    + +
    +
    + +
    +

    YOOO COME JOIN OUR ~~GROOVY~~ CLUB diff --git a/package.json b/package.json index 61aa515..32fe707 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,14 @@ "version": "1.0.0", "description": "![cf](https://i.imgur.com/7v5ASc8.png) Lab 31 - Testing Components ======", "main": "karma.config.js", + "directories": { + "test": "test" + }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "./node_modules/webpack/bin/webpack.js", + "build-watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot", + "test": "./node_modules/karma/bin/karma start --single-run", + "test-watch": "./node_modules/karma/bin/karma start" }, "repository": { "type": "git", diff --git a/test/auth-service-test.js b/test/auth-service-test.js new file mode 100644 index 0000000..0c3223c --- /dev/null +++ b/test/auth-service-test.js @@ -0,0 +1,31 @@ +'use strict'; + +describe('Auth Service', function(){ + + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(( $rootScope, authService, $window, $httpBackend) => { + this.$window = $window; + this.$rootScope = $rootScope; + this.authService = authService; + this.$httpBackend = $httpBackend; + }); + }); + + describe('authService.getToken()', () => { + it('should return a token', () => { + this.authService.token = null; + this.$window.localStorage.setItem('token', 'test token'); + + this.authService.getToken() + .then( token => { + expect(token).toEqual('test token'); + }) + .catch( err => { + expect(err).toEqual(null); + }); + + this.$rootScope.$apply(); + }); + }); +}); diff --git a/test/gallery-item-component-test.js b/test/gallery-item-component-test.js index e69de29..1f72c5f 100644 --- a/test/gallery-item-component-test.js +++ b/test/gallery-item-component-test.js @@ -0,0 +1,63 @@ +'use strict'; + +describe('FRONT END GALLERY ITEM COMPONENT TESTING =======', function() { + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, $componentController, $httpBackend, authService) => { + this.$rootScope = $rootScope; + this.$httpBackend = $httpBackend; + this.$componentController = $componenController; + this.authService = authService; + }) + }); + + describe('galleryItemCtrl.deleteDone (Show Edits Basically)', () => { + it('should successfully call this function', () => { + let mockBindings = { + gallery: { + _id: 'magic mike', + name: 'galleryz', + desc: 'oh sh*t! itz dat gallery bruh!', + pics: [] + }, + + deleteDone: function(data) { + expect(data.galleryData._id).toEqual('magic mike'); + } + }; + + let galleryItemCtrl = this.$componenController('galleryItem', null, mockBindings); + galleryItemCtrl.deleteDone({galleryData: galleryItemCtrl.gallery}); + + this.$rootScope.$apply(); + }); + }); + + it('should call the deleteDone function with a gallery after the galleryDelete', () => { // naming convention of these two functions and their functionality is confusing + let url = `${__API_URL__}`; // recall saying this will work, will run tests to confirm + let headers = { + Authorization: 'Bearer test token', // wont work unless auth services tests have already been set up first. + Accept: 'application/json, text/plain, */*' // bruh why accept changing up on me + }; + + let mockBindings = { + gallery: { + _id: 'magic mike', + name: 'galleryz', + desc: 'oh sh*t! itz dat gallery bruh!', + pics: [] + }, + deleteDone: function(data) { + expect(data.galleryData._id).toEqual(mockBindings.gallery._id); + } + } + + this.$httpBackend.expectDELETE(url, headers).respond(204); + + let galleryItemCtrl = this.$componentController('galleryItem', null, mockBindings); + galleryItemCtrl.deleteGallery(); + + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); +}) From 86c8cdcd13929ff4c987ce6618b7ba688cdc5dc2 Mon Sep 17 00:00:00 2001 From: Shiv Date: Thu, 6 Apr 2017 06:22:14 -0700 Subject: [PATCH 12/13] threw in landing components and the home and landing views from the 6 --- app/component/landing/login/_login.scss | 15 +++++++++++ app/component/landing/login/login.html | 33 +++++++++++++++++++++++ app/component/landing/login/login.js | 27 +++++++++++++++++++ app/component/landing/signup/_signup.scss | 13 +++++++++ app/component/landing/signup/signup.html | 25 +++++++++++++++++ app/component/landing/signup/signup.js | 25 +++++++++++++++++ app/entry.js | 2 +- app/view/home/_home.scss | 0 app/view/home/home-controller.js | 31 +++++++++++++++++++++ app/view/home/home.html | 16 +++++++++++ app/view/landing/_landing.scss | 19 +++++++++++++ app/view/landing/landing-controller.js | 5 ++-- app/view/landing/landing.html | 14 +++++++--- 13 files changed, 219 insertions(+), 6 deletions(-) create mode 100644 app/component/landing/login/_login.scss create mode 100644 app/component/landing/login/login.html create mode 100644 app/component/landing/login/login.js create mode 100644 app/component/landing/signup/_signup.scss create mode 100644 app/component/landing/signup/signup.html create mode 100644 app/component/landing/signup/signup.js create mode 100644 app/view/home/_home.scss create mode 100644 app/view/home/home-controller.js create mode 100644 app/view/home/home.html diff --git a/app/component/landing/login/_login.scss b/app/component/landing/login/_login.scss new file mode 100644 index 0000000..55c83ea --- /dev/null +++ b/app/component/landing/login/_login.scss @@ -0,0 +1,15 @@ +@import "../../../scss/lib/theme/vars"; + +.login-form { + .input-std { + margin-bottom: $gutter-sm; + } + + button { + float: right; + padding-top: 1.5vw; + padding-bottom: 1.5vw; + } + + +} diff --git a/app/component/landing/login/login.html b/app/component/landing/login/login.html new file mode 100644 index 0000000..d43a7bf --- /dev/null +++ b/app/component/landing/login/login.html @@ -0,0 +1,33 @@ +

    diff --git a/app/component/landing/login/login.js b/app/component/landing/login/login.js new file mode 100644 index 0000000..b7b47d1 --- /dev/null +++ b/app/component/landing/login/login.js @@ -0,0 +1,27 @@ +'use strict'; + +require('./_login.scss'); + +module.exports = { + template: require('./login.html'), + controller: ['$log', '$location', 'authService', LoginController], + controllerAs: 'loginCtrl' +}; + +function LoginController($log, $location, authService) { + $log.debug('LoginController'); + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.login = function() { + $log.log('loginCtrl.login()'); + + authService.login(this.user) + .then( () => { + $location.url('/home'); + }); + }; +}; diff --git a/app/component/landing/signup/_signup.scss b/app/component/landing/signup/_signup.scss new file mode 100644 index 0000000..691be8f --- /dev/null +++ b/app/component/landing/signup/_signup.scss @@ -0,0 +1,13 @@ +@import "../../../scss/lib/theme/vars"; + +.signup { + .input-std { + margin-bottom: $gutter-sm; + } + + button { + float: right; + padding-top: 1.5vw; + padding-bottom: 1.5vw; + } +} diff --git a/app/component/landing/signup/signup.html b/app/component/landing/signup/signup.html new file mode 100644 index 0000000..6f59c7e --- /dev/null +++ b/app/component/landing/signup/signup.html @@ -0,0 +1,25 @@ + diff --git a/app/component/landing/signup/signup.js b/app/component/landing/signup/signup.js new file mode 100644 index 0000000..25539d1 --- /dev/null +++ b/app/component/landing/signup/signup.js @@ -0,0 +1,25 @@ +'use strict'; + +module.exports = { + template: require('./signup.html'), + controller: ['$log', '$location', 'authService', SignupController], + controllerAs: 'signupCtrl' +}; + +function SignupController($log, $location, authService) { + $log.debug('SignupController'); + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.signup = function(user) { + $log.debug('signupCtrl.signup()'); + + authService.signup(user) + .then( () => { + $location.url('/home'); + }); + }; +}; diff --git a/app/entry.js b/app/entry.js index ed7c823..e976e6c 100644 --- a/app/entry.js +++ b/app/entry.js @@ -11,7 +11,7 @@ const ngTouch = require('angular-touch'); const ngAnimate = require('angular-animate'); const ngFileUpload = require('ng-file-upload'); -const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter, ngFileUpload]) +const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter, ngFileUpload]); let context = require.context('./config/', true, /\.js$/); context.keys().forEach( path => { diff --git a/app/view/home/_home.scss b/app/view/home/_home.scss new file mode 100644 index 0000000..e69de29 diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js new file mode 100644 index 0000000..1e5dfb1 --- /dev/null +++ b/app/view/home/home-controller.js @@ -0,0 +1,31 @@ +'use strict'; + +require('./_home.scss'); + +module.exports = ['$log', '$rootScope', 'galleryService', HomeController]; + +function HomeController($log, $rootScope, galleryService) { + $log.debug('HomeController'); + + this.galleries = []; + + this.fetchGalleries = function() { + galleryService.fetchGalleries() + .then( galleries => { + this.galleries = galleries; + this.currentGallery = galleries[0]; + }); + }; + + this.galleryDeleteDone = function(gallery) { + if (this.currentGallery._id === gallery._id) { + this.currentGallery = null; + } + } + + this.fetchGalleries(); + + $rootScope.$on('$locationChangeSuccess', () => { + this.fetchGalleries(); + }); +}; diff --git a/app/view/home/home.html b/app/view/home/home.html new file mode 100644 index 0000000..71cdefe --- /dev/null +++ b/app/view/home/home.html @@ -0,0 +1,16 @@ +
    + + + + + +
    diff --git a/app/view/landing/_landing.scss b/app/view/landing/_landing.scss index e69de29..48c6ae7 100644 --- a/app/view/landing/_landing.scss +++ b/app/view/landing/_landing.scss @@ -0,0 +1,19 @@ +@import "../../scss/lib/theme/vars"; + +.join-inner { + + div:last-child { + margin-top: 1.75vw; + text-align: right; + font-size: 2vw; + + p { + display: inline; + margin-right: 1vw; + } + + a { + margin-right: 1.5vw; + } + } +} diff --git a/app/view/landing/landing-controller.js b/app/view/landing/landing-controller.js index 2fcf2d2..d62d677 100644 --- a/app/view/landing/landing-controller.js +++ b/app/view/landing/landing-controller.js @@ -4,7 +4,8 @@ require('./_landing.scss'); module.exports = ['$log', '$location', '$rootScope', 'authService', LandingController]; -function LandingController($log, $location, $rootScope, authService) { +function LandingController($log, $location, authService) { let url = $location.url(); this.showSignup = url === '/join#signup' || url === '/join'; -} +}; + diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html index d5a9c89..ec36e4c 100644 --- a/app/view/landing/landing.html +++ b/app/view/landing/landing.html @@ -4,10 +4,10 @@
    -

    AY MAN YOU ALREADY PART OF THE LANDING SPOT?

    +

    already a member?

    - sign in right hurr. + sign in here.
    @@ -18,4 +18,12 @@
    -

    YOOO COME JOIN OUR ~~GROOVY~~ CLUB +

    want to signup?

    + + sign up here. + +
    +
    +
    +
    From 663e174752a17dbffaa19fcc5fb06d3ac5b0e895 Mon Sep 17 00:00:00 2001 From: Shiv Date: Thu, 6 Apr 2017 06:39:36 -0700 Subject: [PATCH 13/13] auth tests too? ooooohh you diry son of a gun. (untested though so gotta make sure that we staying safe and confirming asap) --- test/auth-service-test.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/auth-service-test.js b/test/auth-service-test.js index 0c3223c..4cd5b47 100644 --- a/test/auth-service-test.js +++ b/test/auth-service-test.js @@ -1,31 +1,31 @@ 'use strict'; -describe('Auth Service', function(){ +describe('WE IN THEM AUTH SERVICES BABY', function() { beforeEach(() => { angular.mock.module('cfgram'); - angular.mock.inject(( $rootScope, authService, $window, $httpBackend) => { + angular.mock.inject(($rootScope, $httpBackend, $window, authService) => { this.$window = $window; this.$rootScope = $rootScope; - this.authService = authService; this.$httpBackend = $httpBackend; + this.authService = authService; }); }); - describe('authService.getToken()', () => { - it('should return a token', () => { + describe('WE GETTING THAT TOKEN BRUH', () => { + it('happy tests for all! You get a happy test! YOU get a happy test!', () => { this.authService.token = null; this.$window.localStorage.setItem('token', 'test token'); - this.authService.getToken() + authService.getToken() .then( token => { expect(token).toEqual('test token'); }) .catch( err => { - expect(err).toEqual(null); + expect(token).toEqual(null); }); this.$rootScope.$apply(); - }); - }); -}); + }) + }) +})