module template and module testing template added, removed promise testing

master
David Kebler 2017-05-29 10:00:12 -07:00
parent 48803ba5fd
commit ddbc8e7aac
9 changed files with 83 additions and 115 deletions

View File

@ -1,13 +0,0 @@
{
"globals": {
"Debug" : true,
/* MOCHA */
"describe" : false,
"it" : false,
"xit" : false,
"before" : false,
"beforeEach" : false,
"after" : false,
"afterEach" : false
}
}

View File

@ -1,70 +0,0 @@
{
// https://gist.github.com/connor/1597131
// Globals - import repo spectific globals
"extends": "./.jshglobals",
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : true,
"rhino" : false,
"couch" : false,
"wsh" : true, // Windows Scripting Host.
"jquery" : true,
"prototypejs" : false,
"mootools" : false,
"dojo" : false,
// Development.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"devel" : true, // Allow developments statements e.g. `console.log();`.
// ECMAScript
"esversion" : 6, //use this in new version of jshint
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
// The Good Parts.
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
"laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"bitwise" : true, // Allow bitwise operators (&, |, ^, etc.).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"eqnull" : false, // Tolerate use of `== null`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : false, // Prohipit variable use before definition.
"loopfunc" : false, // Allow functions to be defined within loops.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"regexp" : true, // Prohibit `.` and `[^...]` in regular expressions.
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
"scripturl" : true, // Tolerate script-targeted URLs.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : true, // Require all non-global variables be declared before they are used.
// Personal styling preferences.
"newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"nomen" : true, // Prohibit use of initial or trailing underbars in names.
"onevar" : false, // Allow only one `var` statement per function.
"plusplus" : false, // Prohibit use of `++` & `--`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"trailing" : true, // Prohibit trailing whitespaces.
"white" : false, // Check against strict whitespace and indentation rules.
"indent" : 2 // Specify indentation spacing
}

View File

@ -1,9 +1,7 @@
language: node_js language: node_js
node_js: node_js:
- '4.0' - '7.10'
- '5.0'
- '6.0'
- 'node' - 'node'
sudo: false sudo: false

View File

@ -1 +0,0 @@
module.exports.hello = function (what) { return 'Hello ' + what }

View File

@ -1 +0,0 @@
module.exports = Promise.resolve('some promise hey')

View File

@ -1,37 +1,37 @@
{ {
"name": "uci-template-changeme", "name": "@uci/changeme",
"version": "0.0.1", "version": "0.0.1",
"description": "A template for a starting a uci package", "description": "A template for a starting a uci package",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"testw": "./node_modules/.bin/mocha --reporter list --recursive --watch", "test": "./node_modules/.bin/mocha --reporter list --watch --timeout 30000",
"test": "istanbul cover ./node_modules/.bin/_mocha test/ --report lcovonly -- -R spec --recursive && codecov || true" "testd": "DEBUG='1:*' ./node_modules/.bin/mocha --reporter list --watch --timeout 30000",
"testd2": "DEBUG='1:*,2:*' ./node_modules/.bin/mocha --reporter list --watch --timeout 30000",
"testd3": "DEBUG='1:*,2:*,3:*' ./node_modules/.bin/mocha --reporter list --watch --timeout 30000",
"testibc": "istanbul cover ./node_modules/.bin/_mocha test/ --report lcovonly -- -R spec --recursive && codecov || true"
}, },
"author": "David Kebler", "author": "David Kebler",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/uCOMmandIt/uci-pkg-template.git" "url": "git+https://github.com/uCOMmandIt/uci-changeme.git"
}, },
"keywords": [ "keywords": [
"node.js", "node.js",
"communication", "I2C",
"serial", "raspberryPi"
"utilities",
"helpers"
], ],
"bugs": { "bugs": {
"url": "https://github.com/uCOMmandIt/uci-pkg-template/issues" "url": "https://github.com/uCOMmandIt/uci-changeme/issues"
}, },
"homepage": "https://github.com/uCOMmandIt/uci-pkg-template#readme", "homepage": "https://github.com/uCOMmandIt/uci-changeme#readme",
"dependencies": { "dependencies": {
"require-all": "git+https://github.com/dkebler/node-require-all.git#merge"
}, },
"devDependencies": { "devDependencies": {
"chai": "^3.5.0", "chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"codecov": "^1.0.1", "codecov": "^1.0.1",
"debug": "^2.6.8",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"mocha": "^3.2.0" "mocha": "^3.x"
} }
} }

View File

@ -17,6 +17,5 @@ You'll need codecov and travis-ci accounts
1. Clone repo 1. Clone repo
2. Edit package.json 2. Edit package.json
3. Edit badge urls changing to your repo path 3. Edit badge urls above changing to repo path
4. Run npm install 4. Start Coding
5. Open a github

22
src/amodule.js Normal file
View File

@ -0,0 +1,22 @@
'use strict'
// **********************************
const
Something = require('apackagemodule')
class aClass extends Something {
constructor(opts = {}) {
super()
this.id = opts.id // must be unique within a bus
this.desc = opts.desc
}
hello(what) { return 'Hello ' + what }
}
module.exports = {
aClass
}

View File

@ -1,17 +1,51 @@
'use strict' 'use strict'
const expect = require('chai').expect, const
lib = require('../') Changeme = require('../src/changeme'),
expect = require('chai').expect,
pause = require('@uci/utils').pPause
//time-stamp for use when watching to distinguish reruns in console describe(
// place in alpha first file only `Testing `,
let date = new Date(Date.now()) function () {
console.log(date.getMinutes(), "\:", date.getSeconds()) hooks()
sometests()
someothertests()
})
describe('Test a template module ', function () { //****************** TESTS **********************
function sometests() {
it('==> test something', async function () {
it('Should test all methods', function () { let result = await someasyncfunction()
expect(lib.hello('Forest Gump')).to.equal('Hello Forest Gump') expect(result, `test failed`).to.equal('expectedresult')
}) await pause(1000)
}) })
}
function someothertests() {
it('==> test something', async function () {
let result = await someasyncfunction()
expect(result, `test failed`).to.equal('expectedresult')
await pause(1000)
})
}
function hooks() {
before(async() => {
await someasyncfunctiontodobefore()
})
beforeEach(async() => {
await someasyncfunctiontodobeforeeachtest()
})
after(async() => {
await someasyncfunctiontodoaftereeachtest()
})
}