diff --git a/README.md b/README.md index 4171bc5..c49ff7b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,21 @@ # Thoughter -Definitely not a Twitter clone. +This project was created for Iron Yard Students to practice Unit testing with +Karma, Mocha and Chai. + +## How to use: + +App uses grunt as a dev dependency. Grunt is configured to copy app js html and +scss files into build directory. Prior to copying js files are linted and tested +using js hint and karma. + +## To set up: + +1. Fork directory from https://github.com/ElizabethBoles/thoughter +2. Run ```npm install``` in your terminal which downloads necessary app dependencies +and developer dependencies (jQuery, Grunt and Grunt task managers). +3. Run ```Grunt build``` to create build directory which then can be used to view app +in preferred browser. + +Testing code and Grunt configuration created by Elizabeth Boles. diff --git a/gruntfile.js b/gruntfile.js new file mode 100644 index 0000000..a3c9b43 --- /dev/null +++ b/gruntfile.js @@ -0,0 +1,117 @@ +module.exports = function configureGrunt(gruntConfig){ + gruntConfig.initConfig({ + clean: [ 'build/' ],//cleaning + + copy: { + + copythehtml: { + files: [ + { + cwd: 'src/',//to get into source + src: [ '*.html' ],//anything that has a html at end + dest: 'build/',//copy file and put that copy in this build dir + expand: true + } + ] + }, + copythejs: { + files: [ + { + cwd: 'src/js/', + src: ['*.js'], + dest: 'build/js/', // slash at the end means i want you to find the js and go in it and thats where i want you to put the files + expand: true + } + ] + }, + copythejquery: {//copying dependency files into js build folder so my app has proper linkage + files: [ + { + cwd: 'node_modules/jquery/dist/', + src: ['jquery.js'],//jquery is js + dest: 'build/js/vendor/',//so now we know the jquery file will be copied into our build/js/vendor folder//then when you run it you can see its created on right + expand: true + } + ] + } + }, + + sass: {//within the sass what we're creating is a task that looks for + //all our sass/css and then compiling all of it into one pile called + //style.css and putting our style.css file in our build directory + //style.css will only ever be in the build + all: {// + // + files: { + //dest/source + //dest - where were gunna put whatever we say is our source into + //> creates a new file called style.css and puts in our main.scss + //and everything that exports into it + 'build/style.css' : 'src/sass/main.scss' + } + } + + }, + + jshint: {//linting + + appjs: { + options: { + jshintrc: '.jshintrc' + }, + files: { + src: [ 'src/**/*.js' ] + } + } + + }, + + karma: {//testing + //configuring karma with grunt letting grunt know that karma works + //with mocha and chai frame works and to launch testing within karma browser + all: { + options: { + frameworks: [ 'mocha', 'chai' ], + browsers: [ 'Chrome' ], + singleRun: true, + files: [//test all of the files that end in extension .js + //when i use my sinnon server find node modules file with that code + //and test code is written my test/specs folder with any file that has + //a .js extention + 'src/**/*.js', + 'node_modules/sinon/pkg/sinon-2.0.0.js', + 'test/specs/**/*.js' + ], + preprocessors: {//what files we want to be pre processed + 'src/**/*.js': ['coverage'],//all the files were testing + //want coverage plug in to watch during those tests + //then generate a summary + //coverage is the plug in and dots is part of how they report + //back + }, + reporters: ['dots', 'coverage'],//in that summary i want + //dots which shows me the number of tests and a color + //indication of whether or not they passed + coverageReporter: { + type: 'text-summary'//so it doesnt come out looking all codey + //makes it look clean in terminal + } + } + } + + } + + + }); + require('load-grunt-tasks')(gruntConfig); + //whenever i run grunt build in my terminal do these things in this order + //out of convention building our build directory + //we dont want to put anything in our build directory thats broken + //thats why first jshint to make sure theres no syntax errors and then why + //i test my files next to make sure nothing breaks and then if those two pass + //i know i have good code so i can copy those files and put into build directory + //the clean task deletes the whole build directory and is the first task that runs + //build = running all of these tasks. you can name it whatever + gruntConfig.registerTask( 'build', [ 'clean', 'jshint', 'karma', 'copy', 'sass' ] ); + //gruntConfig.registerTask( 'watch', ['build']); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..8ffb0cf --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "dandatesting", + "version": "1.0.0", + "description": "", + "main": "thoughter/src/js/recent-thoughts.js", + "scripts": { + "test": "karma start thought.conf.js" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/ElizabethBoles/thoughter.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/ElizabethBoles/thoughter/issues" + }, + "homepage": "https://github.com/ElizabethBoles/thoughter#readme", + "devDependencies": { + "chai": "^3.5.0", + "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", + "grunt-karma": "^2.0.0", + "karma": "^1.5.0", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^2.0.0", + "karma-coverage": "^1.1.1", + "karma-mocha": "^1.3.0", + "load-grunt-tasks": "^3.5.2", + "mocha": "^3.2.0", + "sinon": "^2.0.0" + }, + "dependencies": { + "jquery": "^3.2.0" + } +} diff --git a/src/index.html b/src/index.html index d257fa8..e40156f 100644 --- a/src/index.html +++ b/src/index.html @@ -16,6 +16,8 @@