From 480f6ec9492520b59dad1eebd4e49d5216bc4a45 Mon Sep 17 00:00:00 2001 From: Jordan Kasper Date: Sat, 11 Mar 2017 16:58:09 -0500 Subject: [PATCH 01/21] Added Sass code and new thought JS --- src/index.html | 21 +++++++++++++++++++++ src/js/new-thought.js | 35 +++++++++++++++++++++++++++++++++++ src/sass/header.scss | 10 ++++++++++ src/sass/login.scss | 7 +++++++ src/sass/main.scss | 6 ++++++ src/sass/recent.scss | 10 ++++++++++ src/sass/variables.scss | 11 +++++++++++ 7 files changed, 100 insertions(+) create mode 100644 src/index.html create mode 100644 src/js/new-thought.js create mode 100644 src/sass/header.scss create mode 100644 src/sass/login.scss create mode 100644 src/sass/main.scss create mode 100644 src/sass/recent.scss create mode 100644 src/sass/variables.scss diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..d257fa8 --- /dev/null +++ b/src/index.html @@ -0,0 +1,21 @@ + + + + + Thoughter + + + + + + +
+

Thoughter

+
+ + + + + + + diff --git a/src/js/new-thought.js b/src/js/new-thought.js new file mode 100644 index 0000000..cd2d613 --- /dev/null +++ b/src/js/new-thought.js @@ -0,0 +1,35 @@ +(function() { + + window.thoughter = window.thoughter || {}; + + /** + * Creates a new thought with the given text + * + * @param {String} text The text to use for the thought - this is REQUIRED! + * @return {Promise} The resolved promise will have the new thought data object in it + */ + window.thoughter.createThought = function createThought(text) { + if (typeof(text) !== 'string' || !text.length) { + return Promise.reject('Please provide text for this new thought'); + } + + return fetch( + 'http://thoughter.herokuapp.com/api/Thoughts', + { + method: 'post', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ content: text }) + } + ) + .then(function handleResponse(res) { + if (res.status > 299) { + console.error('Looks like a bad status code:', res.status); + } else { + return res.json() + } + }); + }; + +})(); diff --git a/src/sass/header.scss b/src/sass/header.scss new file mode 100644 index 0000000..aed64e2 --- /dev/null +++ b/src/sass/header.scss @@ -0,0 +1,10 @@ + +header { + border-bottom: $themeBorder; + + h1 { + font-size: $topHeaderFontSize; + font-weight: bold; + margin-left: $topHeaderShift; + } +} diff --git a/src/sass/login.scss b/src/sass/login.scss new file mode 100644 index 0000000..2a0f74b --- /dev/null +++ b/src/sass/login.scss @@ -0,0 +1,7 @@ + +.login { + form { + width: $loginWidth; + margin: 0 auto; + } +} diff --git a/src/sass/main.scss b/src/sass/main.scss new file mode 100644 index 0000000..affe303 --- /dev/null +++ b/src/sass/main.scss @@ -0,0 +1,6 @@ + +@import 'variables'; +@import 'header'; +@import 'login'; +@import 'new-thought'; +@import 'recent'; diff --git a/src/sass/recent.scss b/src/sass/recent.scss new file mode 100644 index 0000000..938e465 --- /dev/null +++ b/src/sass/recent.scss @@ -0,0 +1,10 @@ + +.recent { + width: $recentContainerWidth; + margin: 0 auto; + display: flex; + + article { + flex: 0 0 calc((100% / $thoughtColumns) - $thoughtMargin); + } +} diff --git a/src/sass/variables.scss b/src/sass/variables.scss new file mode 100644 index 0000000..85ac3f8 --- /dev/null +++ b/src/sass/variables.scss @@ -0,0 +1,11 @@ + +$themeFontColor: #222222; +$themeBorder: 1px solid #99bbff; +$topHeaderFontSize: 1.2em; +$topHeaderShift: 5em; + +$loginWidth: 60%; + +$recentContainerWidth: 90%; +$thoughtColumns: 2; +$thoughtMargin: 2em; From 61ed5414cc6d238da2054d19c8e9f5859ab87d2f Mon Sep 17 00:00:00 2001 From: Jordan Kasper Date: Sat, 11 Mar 2017 17:53:52 -0500 Subject: [PATCH 02/21] Added rejected promise on non-200 status code for new thoughts --- src/js/new-thought.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/new-thought.js b/src/js/new-thought.js index cd2d613..f56e972 100644 --- a/src/js/new-thought.js +++ b/src/js/new-thought.js @@ -26,6 +26,7 @@ .then(function handleResponse(res) { if (res.status > 299) { console.error('Looks like a bad status code:', res.status); + return Promise.reject('Sorry, but there was a problem with your request.'); } else { return res.json() } From b5dbcf037c24df48f6f499cc59e68396e69d954a Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 20:43:37 -0400 Subject: [PATCH 03/21] passed my first test! --- src/specs/thoughter.specs.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/specs/thoughter.specs.js diff --git a/src/specs/thoughter.specs.js b/src/specs/thoughter.specs.js new file mode 100644 index 0000000..9afcb75 --- /dev/null +++ b/src/specs/thoughter.specs.js @@ -0,0 +1,29 @@ +(function() { + 'use strict'; + let expect = chai.expect; + + describe('test run', function(){ + it('should be true', function(){ + expect(true).to.be.true; + }); + describe('recent module', function(){ + describe('show recent function', function(){ + beforeEach(function(){ + // I need to add an element with a class of recent + let recentTag = document.createElement('main'); + recentTag.className = 'recent'; + document.querySelector('body').appendChild(recentTag); + }); + + it('should be a function', function(){ + expect(window.thoughter.showRecent).to.be.a('function'); + + }); + + + }); + + + }); + }); +}()); From ef4ca951934076da1dbdbc4ac35646abd10ef0d6 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 20:45:38 -0400 Subject: [PATCH 04/21] i detailed what the lines should do for personal reference --- src/js/recent-thoughts.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/js/recent-thoughts.js b/src/js/recent-thoughts.js index c548e79..dab88ad 100644 --- a/src/js/recent-thoughts.js +++ b/src/js/recent-thoughts.js @@ -10,25 +10,36 @@ * @return {void} */ window.thoughter.showRecent = function showRecent(thoughts = []) { + // this is creating a function (showRecent)which takes an arg (thought = []) if (!Array.isArray(thoughts)) { + //if (thoughts) is not an array return nothing, return; } - recent = document.querySelector('.recent'); - thoughts.forEach(function showThought(thought) { + let recent = document.querySelector('.recent'); + //selecting an element with the class name of recent and defining recent + thoughts.forEach(function showThought(thoughts) { + //for each object in the array called thoughts if (!thought.content || !thought.createTime || !thought.id) { + //if the thought has no content or createTime or an id we don't want it, so we return return; } let thoughtUI = document.createElement('article'); + //creating an element (article) while setting it to a variable thoughtUI.classList.add('panel'); + //adding the class panel to the article 'thoughtUI' thoughtUI.classList.add('panel-info'); + //adding class panel-info to the article 'thoughtUI' thoughtUI.setAttribute('id', 'thought-' + thought.id); + //setting an id to thoughtUI thoughtUI.innerHTML = `
Posted ${thoughts.createTime}

${thought.content}

`; + //adding HTML to the article recent.appendChild(thoughtUI); + //adding the recent class to the article thoughtUI }); }; From d3a73c892b6f1b8f7240d28cc749be60c37399d0 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 22:36:45 -0400 Subject: [PATCH 05/21] ading root files --- package.json | 36 ++++++++++++++++++++++++++++++++++++ thoughter.conf.js | 16 ++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 package.json create mode 100644 thoughter.conf.js diff --git a/package.json b/package.json new file mode 100644 index 0000000..f5cc64b --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "wk5-day3", + "version": "1.0.0", + "description": "this is code for homework", + "main": "src/js/recent-thoughts.js", + "dependencies": { + "chai": "^3.5.0", + "karma": "^1.5.0", + "karma-chrome-launcher": "^2.0.0", + "karma-chai": "^0.1.0", + "karma-mocha": "^1.3.0", + "sinon": "^2.0.0" + }, + "devDependencies": { + "chai": "^3.5.0", + "karma": "^1.5.0", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^2.0.0", + "karma-mocha": "^1.3.0", + "mocha": "^3.2.0", + "sinon": "^2.0.0" + }, + "scripts": { + "test": "karma start thoughter.conf.js" + }, + "author": "Carlyse Jordan", + "license": "ISC", + "repository": { + "type": "git", + "url": "git+https://github.com/Carlysej89/thoughter.git" + }, + "bugs": { + "url": "https://github.com/Carlysej89/thoughter/issues" + }, + "homepage": "https://github.com/Carlysej89/thoughter#readme" +} diff --git a/thoughter.conf.js b/thoughter.conf.js new file mode 100644 index 0000000..2a3a859 --- /dev/null +++ b/thoughter.conf.js @@ -0,0 +1,16 @@ +module.exports = function karmaConfig( config ){ + config.set({ + // Karma will inject the mocha and chai JS files into its test runner HTMl + + frameworks: ['mocha', 'chai'], + browsers: ['Chrome'], + singleRun: true, + files: [ + 'src/**/*.js', + //globbing pattern - look an the src/ directory and ANY subdirectory + //for ANY file that ends in .js + 'node_modules/sinon/pkg/sinon-2.0.0.js', + 'tests/specs/**/*.js' + ] + }); +}; From 96f2d2d41e92c744d8ced37786c7539128e9e141 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 23:09:55 -0400 Subject: [PATCH 06/21] added the afterEach portion of the test --- src/specs/thoughter.specs.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/specs/thoughter.specs.js b/src/specs/thoughter.specs.js index 9afcb75..0aff918 100644 --- a/src/specs/thoughter.specs.js +++ b/src/specs/thoughter.specs.js @@ -15,15 +15,20 @@ document.querySelector('body').appendChild(recentTag); }); - it('should be a function', function(){ - expect(window.thoughter.showRecent).to.be.a('function'); + afterEach(function(){ - }); + let recentTag = document.querySelector('main'); + recentTag.className = 'recent'; + recentTag.parentNode.removeChild(recentTag); + }); + it('should be a function', function(){ + expect(window.thoughter.showRecent).to.be.a('function'); }); }); }); +}); }()); From 8007fce406b160f7745927467a3787a93227438f Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 23:27:22 -0400 Subject: [PATCH 07/21] while only two of my tests passed one has failed --- src/specs/thoughter.specs.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/specs/thoughter.specs.js b/src/specs/thoughter.specs.js index 0aff918..a403391 100644 --- a/src/specs/thoughter.specs.js +++ b/src/specs/thoughter.specs.js @@ -26,9 +26,19 @@ expect(window.thoughter.showRecent).to.be.a('function'); }); - + it('should check for all the properties in each array', function(){ + window.thoughter.showRecent([ + { + content: '', + createTime: '', + id: ' ' + } + ]); + let recent = document.querySelectorAll('main.recent article'); + expect(recent.length).to.equal(1); + }); + }); }); }); -}); }()); From 971d898a07e0932a22b2a135bf6057c9c9f6e751 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 23:28:28 -0400 Subject: [PATCH 08/21] commented out the getRecent function --- src/js/recent-thoughts.js | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/js/recent-thoughts.js b/src/js/recent-thoughts.js index dab88ad..4a446ef 100644 --- a/src/js/recent-thoughts.js +++ b/src/js/recent-thoughts.js @@ -43,28 +43,28 @@ }); }; - /** - * Retrieves the most recent thoughts, using the provided count as the limit - * - * @param {Number} count How many thoughts to limit to, must be a positive number (defaults to 10) - * @return {Promise} The resolved promise will have the data array as the argument - */ - window.thoughter.getRecent = function getRecent(count = 10) { - if (typeof(count) !== 'number' || count < 1) { - return Promise.reject('Sorry, but the count must be a positive number'); - } - - return fetch( - 'http://thoughter.herokuapp.com/api/Thoughts?filter={"order":"createTime DESC","limit":' + count + '}' - ) - .then(function handleResponse(res) { - if (res.status > 299) { - console.error('Looks like a bad status code:', res.status); - return Promise.reject('Sorry, but there was a problem with your request.'); - } else { - return res.json(); - } - }); - }; + // /** + // * Retrieves the most recent thoughts, using the provided count as the limit + // * + // * @param {Number} count How many thoughts to limit to, must be a positive number (defaults to 10) + // * @return {Promise} The resolved promise will have the data array as the argument + // */ + // window.thoughter.getRecent = function getRecent(count = 10) { + // if (typeof(count) !== 'number' || count < 1) { + // return Promise.reject('Sorry, but the count must be a positive number'); + // } + // + // return fetch( + // 'http://thoughter.herokuapp.com/api/Thoughts?filter={"order":"createTime DESC","limit":' + count + '}' + // ) + // .then(function handleResponse(res) { + // if (res.status > 299) { + // console.error('Looks like a bad status code:', res.status); + // return Promise.reject('Sorry, but there was a problem with your request.'); + // } else { + // return res.json(); + // } + // }); + // }; })(); From 3e55d4a8502715a8dedfd43495b3273245c23cba Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 16 Mar 2017 23:34:19 -0400 Subject: [PATCH 09/21] added more definition to my README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 4171bc5..7207e89 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,11 @@ # Thoughter Definitely not a Twitter clone. + +Edited by: Carlyse Jordan +TIY +03/16/17 + +This was a homework exercise used to get more practice with asynchronous DOM +and ajax testing using tools such as mocha(describe/module library), chai(assertion +framework) and karma as the test runner. From 14a52e18e928feed053933b306dad4a2bdfaa2b4 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Fri, 17 Mar 2017 15:28:26 -0400 Subject: [PATCH 10/21] completed copy clean and build tasks --- gruntfile.js | 24 ++++++++++++++++++++++++ package.json | 4 ++++ 2 files changed, 28 insertions(+) create mode 100644 gruntfile.js diff --git a/gruntfile.js b/gruntfile.js new file mode 100644 index 0000000..64cabf2 --- /dev/null +++ b/gruntfile.js @@ -0,0 +1,24 @@ +module.exports = function configureGrunt(gruntConfig){ + + gruntConfig.initConfig({ + clean: ['build/'], + + copy: { + htmlcopy: { + + files: [ { + src: 'src/*.html', + dest: 'build/', + expand: true + } + ] + } + } + + }); + require('load-grunt-tasks')(gruntConfig); + + //create a task called "alias" to run multiple OTHER tasks + //can create more aliases! + gruntConfig.registerTask('build',['clean','copy']); +}; diff --git a/package.json b/package.json index f5cc64b..607e114 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,14 @@ }, "devDependencies": { "chai": "^3.5.0", + "grunt": "^1.0.1", + "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-copy": "^1.0.0", "karma": "^1.5.0", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.0.0", "karma-mocha": "^1.3.0", + "load-grunt-tasks": "^3.5.2", "mocha": "^3.2.0", "sinon": "^2.0.0" }, From c6b9382abf5d858dee8b4e9d07010eaca5e67c42 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Fri, 17 Mar 2017 15:29:08 -0400 Subject: [PATCH 11/21] src file --- src/recent-thoughts.js | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/recent-thoughts.js diff --git a/src/recent-thoughts.js b/src/recent-thoughts.js new file mode 100644 index 0000000..4a446ef --- /dev/null +++ b/src/recent-thoughts.js @@ -0,0 +1,70 @@ +(function() { + 'use strict'; + + window.thoughter = window.thoughter || {}; + + /** + * Shows the provided thought data on the page in the `.recent` element + * + * @param {Array} thoughts The array of thought objects to display + * @return {void} + */ + window.thoughter.showRecent = function showRecent(thoughts = []) { + // this is creating a function (showRecent)which takes an arg (thought = []) + if (!Array.isArray(thoughts)) { + //if (thoughts) is not an array return nothing, + return; + } + + let recent = document.querySelector('.recent'); + //selecting an element with the class name of recent and defining recent + thoughts.forEach(function showThought(thoughts) { + //for each object in the array called thoughts + if (!thought.content || !thought.createTime || !thought.id) { + //if the thought has no content or createTime or an id we don't want it, so we return + return; + } + + let thoughtUI = document.createElement('article'); + //creating an element (article) while setting it to a variable + thoughtUI.classList.add('panel'); + //adding the class panel to the article 'thoughtUI' + thoughtUI.classList.add('panel-info'); + //adding class panel-info to the article 'thoughtUI' + thoughtUI.setAttribute('id', 'thought-' + thought.id); + //setting an id to thoughtUI + thoughtUI.innerHTML = `
Posted ${thoughts.createTime}
+
+

${thought.content}

+
`; + //adding HTML to the article + recent.appendChild(thoughtUI); + //adding the recent class to the article thoughtUI + }); + }; + + // /** + // * Retrieves the most recent thoughts, using the provided count as the limit + // * + // * @param {Number} count How many thoughts to limit to, must be a positive number (defaults to 10) + // * @return {Promise} The resolved promise will have the data array as the argument + // */ + // window.thoughter.getRecent = function getRecent(count = 10) { + // if (typeof(count) !== 'number' || count < 1) { + // return Promise.reject('Sorry, but the count must be a positive number'); + // } + // + // return fetch( + // 'http://thoughter.herokuapp.com/api/Thoughts?filter={"order":"createTime DESC","limit":' + count + '}' + // ) + // .then(function handleResponse(res) { + // if (res.status > 299) { + // console.error('Looks like a bad status code:', res.status); + // return Promise.reject('Sorry, but there was a problem with your request.'); + // } else { + // return res.json(); + // } + // }); + // }; + +})(); From 3d2d09073166c33923e5328964981609fc821e9d Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Fri, 17 Mar 2017 16:09:00 -0400 Subject: [PATCH 12/21] compiled sass file --- src/sass/main.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sass/main.scss b/src/sass/main.scss index affe303..c915712 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -2,5 +2,5 @@ @import 'variables'; @import 'header'; @import 'login'; -@import 'new-thought'; +//@import 'new-thought'; @import 'recent'; From 84430f3a989f7b5ba53010899dfede937ddd3176 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Fri, 17 Mar 2017 16:12:41 -0400 Subject: [PATCH 13/21] added sass and updated grunt file --- gruntfile.js | 9 ++++++++- package.json | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index 64cabf2..4a396fd 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -13,6 +13,13 @@ module.exports = function configureGrunt(gruntConfig){ } ] } + }, + sass: { + all: { + files: { + 'build/style.csss':'src/sass/main.scss' + } + } } }); @@ -20,5 +27,5 @@ module.exports = function configureGrunt(gruntConfig){ //create a task called "alias" to run multiple OTHER tasks //can create more aliases! - gruntConfig.registerTask('build',['clean','copy']); + gruntConfig.registerTask('build',['clean','copy','sass']); }; diff --git a/package.json b/package.json index 607e114..28ca4a0 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "grunt": "^1.0.1", "grunt-contrib-clean": "^1.0.0", "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-sass": "^1.0.0", "karma": "^1.5.0", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.0.0", From 21b2c6a7807854d3aa9127650af86ad2fd3960ab Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Mon, 20 Mar 2017 08:54:04 -0400 Subject: [PATCH 14/21] adding updated package.json file and gruntfile.js --- gruntfile.js | 12 +++++++++++- package.json | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index 4a396fd..e434234 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -20,6 +20,16 @@ module.exports = function configureGrunt(gruntConfig){ 'build/style.csss':'src/sass/main.scss' } } + }, + jshint: { + appjs: { + options: { + jshintrc: '.jshintrc' + }, + files: { + src: ['src/**/*.js'] + } + } } }); @@ -27,5 +37,5 @@ module.exports = function configureGrunt(gruntConfig){ //create a task called "alias" to run multiple OTHER tasks //can create more aliases! - gruntConfig.registerTask('build',['clean','copy','sass']); + gruntConfig.registerTask('build',['jshint','clean','copy','sass']); }; diff --git a/package.json b/package.json index 28ca4a0..1074b41 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "grunt": "^1.0.1", "grunt-contrib-clean": "^1.0.0", "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-jshint": "^1.1.0", "grunt-contrib-sass": "^1.0.0", + "jquery": "^3.2.0", "karma": "^1.5.0", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.0.0", From 844fb663358fca18f4eb0a8d3756c188047a1081 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Mon, 20 Mar 2017 08:57:57 -0400 Subject: [PATCH 15/21] gruntfile update --- gruntfile.js | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index e434234..5f0d2b5 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -14,6 +14,29 @@ module.exports = function configureGrunt(gruntConfig){ ] } }, + copythejquery: { + files: [ + { + cwd: 'node_modules/jquery/dist', + src: ['jquery.js'], + dest: 'build/js/vendor/', + expand: true + } + ] + + }, + + copythejs:{ + files: [ + { + cwd: 'src/js', + src: ['*.js'], + dest: 'build/js/', + expand: true + } + ] + }, + sass: { all: { files: { @@ -21,7 +44,7 @@ module.exports = function configureGrunt(gruntConfig){ } } }, - jshint: { + jshint: { appjs: { options: { jshintrc: '.jshintrc' @@ -30,6 +53,23 @@ module.exports = function configureGrunt(gruntConfig){ src: ['src/**/*.js'] } } + }, + karma: { + all: { + + options:{ + //if Im using grunt to run karma (tests), then we DON'T need a app.conf.js + //file for karma separatelly + //Same options from Conf.js file + frameworks: ['mocha', 'chai'], + browsers: ['Chrome'], + singleRun: true, + files: [ + 'src/**/*.js', + 'tests/specs/**/*.js' + ] + } + } } }); @@ -37,5 +77,5 @@ module.exports = function configureGrunt(gruntConfig){ //create a task called "alias" to run multiple OTHER tasks //can create more aliases! - gruntConfig.registerTask('build',['jshint','clean','copy','sass']); + gruntConfig.registerTask('build',['jshint','karma','clean','copy','sass']); }; From 594fd83ee1c0b287bb31c90d13e205a4b7827be0 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Mon, 20 Mar 2017 09:42:57 -0400 Subject: [PATCH 16/21] gruntfile package.json danges --- gruntfile.js | 6 +++--- package.json | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 5f0d2b5..b9c94b1 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -29,9 +29,9 @@ module.exports = function configureGrunt(gruntConfig){ copythejs:{ files: [ { - cwd: 'src/js', - src: ['*.js'], - dest: 'build/js/', + cwd: 'src/', + src: ['**/*.js'], + dest: 'build/', expand: true } ] diff --git a/package.json b/package.json index 1074b41..6f7a6bb 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,6 @@ "dependencies": { "chai": "^3.5.0", "karma": "^1.5.0", - "karma-chrome-launcher": "^2.0.0", - "karma-chai": "^0.1.0", - "karma-mocha": "^1.3.0", - "sinon": "^2.0.0" }, "devDependencies": { "chai": "^3.5.0", @@ -20,12 +16,8 @@ "grunt-contrib-sass": "^1.0.0", "jquery": "^3.2.0", "karma": "^1.5.0", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^2.0.0", - "karma-mocha": "^1.3.0", "load-grunt-tasks": "^3.5.2", "mocha": "^3.2.0", - "sinon": "^2.0.0" }, "scripts": { "test": "karma start thoughter.conf.js" From c2925e61ff6767643416fb4c8e4300f0494a2ec6 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Mon, 20 Mar 2017 22:00:54 -0400 Subject: [PATCH 17/21] commiting updated grunt --- gruntfile.js | 113 +++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index b9c94b1..ec9ee63 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -10,72 +10,71 @@ module.exports = function configureGrunt(gruntConfig){ src: 'src/*.html', dest: 'build/', expand: true - } - ] + } + ] + } + }, + copythejquery: { + files: [ + { + src: ['jquery.js'], + dest: 'build/js/vendor/', + expand: true } - }, - copythejquery: { - files: [ - { - cwd: 'node_modules/jquery/dist', - src: ['jquery.js'], - dest: 'build/js/vendor/', - expand: true - } - ] + ] - }, + }, - copythejs:{ - files: [ - { - cwd: 'src/', - src: ['**/*.js'], - dest: 'build/', - expand: true - } - ] - }, + copythejs:{ + files: [ + { + cwd: 'src/', + src: ['**/*.js'], + dest: 'build/', + expand: true + } + ] + }, - sass: { - all: { - files: { - 'build/style.csss':'src/sass/main.scss' - } + sass: { + all: { + files: { + 'build/style.csss':'src/sass/main.scss' } - }, - jshint: { - appjs: { - options: { - jshintrc: '.jshintrc' - }, - files: { - src: ['src/**/*.js'] - } + } + }, + jshint: { + appjs: { + options: { + jshintrc: '.jshintrc' + }, + files: { + src: ['src/**/*.js'] } - }, - karma: { - all: { + } + }, + karma: { + all: { - options:{ - //if Im using grunt to run karma (tests), then we DON'T need a app.conf.js - //file for karma separatelly - //Same options from Conf.js file - frameworks: ['mocha', 'chai'], - browsers: ['Chrome'], - singleRun: true, - files: [ - 'src/**/*.js', - 'tests/specs/**/*.js' - ] - } + options:{ + //if Im using grunt to run karma (tests), then we DON'T need a app.conf.js + //file for karma separatelly + //Same options from Conf.js file + frameworks: ['mocha', 'chai'], + browsers: ['Chrome'], + singleRun: true, + files: [ + 'src/**/*.js', + 'tests/specs/**/*.js' + ] } } + } - }); - require('load-grunt-tasks')(gruntConfig); +}); +require('load-grunt-tasks')(gruntConfig); - //create a task called "alias" to run multiple OTHER tasks - //can create more aliases! - gruntConfig.registerTask('build',['jshint','karma','clean','copy','sass']); +//create a task called "alias" to run multiple OTHER tasks +//can create more aliases! +gruntConfig.registerTask('build',['jshint','karma','clean','copy','sass']); }; From f4ca994bb655be8847734b9a18b7ae25700d04fb Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Tue, 4 Apr 2017 17:56:44 -0400 Subject: [PATCH 18/21] fixed indentation --- src/recent-thoughts.js | 124 +++++++++++++++++------------------ src/specs/thoughter.specs.js | 20 +++--- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/recent-thoughts.js b/src/recent-thoughts.js index 4a446ef..ed6a2d7 100644 --- a/src/recent-thoughts.js +++ b/src/recent-thoughts.js @@ -1,70 +1,70 @@ (function() { - 'use strict'; + 'use strict'; - window.thoughter = window.thoughter || {}; + window.thoughter = window.thoughter || {}; - /** - * Shows the provided thought data on the page in the `.recent` element - * - * @param {Array} thoughts The array of thought objects to display - * @return {void} - */ - window.thoughter.showRecent = function showRecent(thoughts = []) { - // this is creating a function (showRecent)which takes an arg (thought = []) - if (!Array.isArray(thoughts)) { - //if (thoughts) is not an array return nothing, - return; - } + /** + * Shows the provided thought data on the page in the `.recent` element + * + * @param {Array} thoughts The array of thought objects to display + * @return {void} + */ + window.thoughter.showRecent = function showRecent(thoughts = []) { + // this is creating a function (showRecent)which takes an arg (thought = []) + if (!Array.isArray(thoughts)) { + //if (thoughts) is not an array return nothing, + return; + } - let recent = document.querySelector('.recent'); - //selecting an element with the class name of recent and defining recent - thoughts.forEach(function showThought(thoughts) { - //for each object in the array called thoughts - if (!thought.content || !thought.createTime || !thought.id) { - //if the thought has no content or createTime or an id we don't want it, so we return - return; - } + let recent = document.querySelector('.recent'); + //selecting an element with the class name of recent and defining recent + thoughts.forEach(function showThought(thoughts) { + //for each object in the array called thoughts + if (!thought.content || !thought.createTime || !thought.id) { + //if the thought has no content or createTime or an id we don't want it, so we return + return; + } - let thoughtUI = document.createElement('article'); - //creating an element (article) while setting it to a variable - thoughtUI.classList.add('panel'); - //adding the class panel to the article 'thoughtUI' - thoughtUI.classList.add('panel-info'); - //adding class panel-info to the article 'thoughtUI' - thoughtUI.setAttribute('id', 'thought-' + thought.id); - //setting an id to thoughtUI - thoughtUI.innerHTML = `
Posted ${thoughts.createTime}
-
-

${thought.content}

-
`; - //adding HTML to the article - recent.appendChild(thoughtUI); - //adding the recent class to the article thoughtUI - }); - }; + let thoughtUI = document.createElement('article'); + //creating an element (article) while setting it to a variable + thoughtUI.classList.add('panel'); + //adding the class panel to the article 'thoughtUI' + thoughtUI.classList.add('panel-info'); + //adding class panel-info to the article 'thoughtUI' + thoughtUI.setAttribute('id', 'thought-' + thought.id); + //setting an id to thoughtUI + thoughtUI.innerHTML = `
Posted ${thoughts.createTime}
+
+

${thought.content}

+
`; + //adding HTML to the article + recent.appendChild(thoughtUI); + //adding the recent class to the article thoughtUI + }); + }; - // /** - // * Retrieves the most recent thoughts, using the provided count as the limit - // * - // * @param {Number} count How many thoughts to limit to, must be a positive number (defaults to 10) - // * @return {Promise} The resolved promise will have the data array as the argument - // */ - // window.thoughter.getRecent = function getRecent(count = 10) { - // if (typeof(count) !== 'number' || count < 1) { - // return Promise.reject('Sorry, but the count must be a positive number'); - // } - // - // return fetch( - // 'http://thoughter.herokuapp.com/api/Thoughts?filter={"order":"createTime DESC","limit":' + count + '}' - // ) - // .then(function handleResponse(res) { - // if (res.status > 299) { - // console.error('Looks like a bad status code:', res.status); - // return Promise.reject('Sorry, but there was a problem with your request.'); - // } else { - // return res.json(); - // } - // }); - // }; + // /** + // * Retrieves the most recent thoughts, using the provided count as the limit + // * + // * @param {Number} count How many thoughts to limit to, must be a positive number (defaults to 10) + // * @return {Promise} The resolved promise will have the data array as the argument + // */ + // window.thoughter.getRecent = function getRecent(count = 10) { + // if (typeof(count) !== 'number' || count < 1) { + // return Promise.reject('Sorry, but the count must be a positive number'); + // } + // + // return fetch( + // 'http://thoughter.herokuapp.com/api/Thoughts?filter={"order":"createTime DESC","limit":' + count + '}' + // ) + // .then(function handleResponse(res) { + // if (res.status > 299) { + // console.error('Looks like a bad status code:', res.status); + // return Promise.reject('Sorry, but there was a problem with your request.'); + // } else { + // return res.json(); + // } + // }); + // }; })(); diff --git a/src/specs/thoughter.specs.js b/src/specs/thoughter.specs.js index a403391..658daba 100644 --- a/src/specs/thoughter.specs.js +++ b/src/specs/thoughter.specs.js @@ -25,19 +25,19 @@ it('should be a function', function(){ expect(window.thoughter.showRecent).to.be.a('function'); - }); + }); it('should check for all the properties in each array', function(){ window.thoughter.showRecent([ - { - content: '', - createTime: '', - id: ' ' - } - ]); - let recent = document.querySelectorAll('main.recent article'); - expect(recent.length).to.equal(1); - }); + { + content: '', + createTime: '', + id: ' ' + } + ]); + let recent = document.querySelectorAll('main.recent article'); + expect(recent.length).to.equal(1); }); + }); }); }); From 68f79f412d5f23379da7b4c9ed4e18e480f2d6c9 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Tue, 4 Apr 2017 17:57:17 -0400 Subject: [PATCH 19/21] fixed the indentation --- thoughter.conf.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/thoughter.conf.js b/thoughter.conf.js index 2a3a859..9a171b7 100644 --- a/thoughter.conf.js +++ b/thoughter.conf.js @@ -1,16 +1,16 @@ module.exports = function karmaConfig( config ){ - config.set({ - // Karma will inject the mocha and chai JS files into its test runner HTMl + config.set({ + // Karma will inject the mocha and chai JS files into its test runner HTMl - frameworks: ['mocha', 'chai'], - browsers: ['Chrome'], - singleRun: true, - files: [ - 'src/**/*.js', - //globbing pattern - look an the src/ directory and ANY subdirectory - //for ANY file that ends in .js - 'node_modules/sinon/pkg/sinon-2.0.0.js', - 'tests/specs/**/*.js' - ] - }); + frameworks: ['mocha', 'chai'], + browsers: ['Chrome'], + singleRun: true, + files: [ + 'src/**/*.js', + //globbing pattern - look an the src/ directory and ANY subdirectory + //for ANY file that ends in .js + 'node_modules/sinon/pkg/sinon-2.0.0.js', + 'tests/specs/**/*.js' + ] + }); }; From ee48348ec0f1606fc106e0f85c984d0e0aa93e23 Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Tue, 4 Apr 2017 17:57:47 -0400 Subject: [PATCH 20/21] added npm log --- npm-debug.log | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 npm-debug.log diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..f5b27e5 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,39 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'install' ] +2 info using npm@3.10.10 +3 info using node@v6.9.5 +4 silly loadCurrentTree Starting +5 silly install loadCurrentTree +6 silly install readLocalPackageData +7 silly rollbackFailedOptional Starting +8 silly rollbackFailedOptional Finishing +9 silly runTopLevelLifecycles Finishing +10 silly install printInstalled +11 verbose stack Error: Failed to parse json +11 verbose stack Trailing comma in object at 9:3 +11 verbose stack }, +11 verbose stack ^ +11 verbose stack at parseError (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:390:11) +11 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:79:23) +11 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:48:5 +11 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 +11 verbose stack at tryToString (fs.js:455:3) +11 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12) +12 verbose cwd /Users/carlyse.jordan/TIYDC/wk5-day3/thoughter +13 error Darwin 15.6.0 +14 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" +15 error node v6.9.5 +16 error npm v3.10.10 +17 error file /Users/carlyse.jordan/TIYDC/wk5-day3/thoughter/package.json +18 error code EJSONPARSE +19 error Failed to parse json +19 error Trailing comma in object at 9:3 +19 error }, +19 error ^ +20 error File: /Users/carlyse.jordan/TIYDC/wk5-day3/thoughter/package.json +21 error Failed to parse package.json data. +21 error package.json must be actual JSON, not just JavaScript. +21 error +21 error This is not a bug in npm. +21 error Tell the package author to fix their package.json file. JSON.parse +22 verbose exit [ 1, true ] From d78f321f542054c9b374bf77b823c616b5b55d2c Mon Sep 17 00:00:00 2001 From: Carlyse Jordan Date: Thu, 6 Apr 2017 10:45:02 -0400 Subject: [PATCH 21/21] Set theme jekyll-theme-architect --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..3397c9a --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-architect \ No newline at end of file