Skip to content

Commit

Permalink
first skeleton of a test
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj committed Oct 12, 2015
1 parent e24805d commit f2eeaaf
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- "4.1"
- "4.0"
2 changes: 1 addition & 1 deletion jspm-hot-reloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class JspmHotReloader extends Emitter {
}
hotReload (moduleName) {
const self = this

this.moduleRecordsBackup = cloneDeep(System._loader.moduleRecords) // in case some module fails to import
this.modulesJustDeleted = {}
return this.getModuleRecord(moduleName).then(module => {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"precommit": "npm test",
"pretest": "node_modules/.bin/standard",
"test": "mocha"
"test": "node run-tests"
},
"repository": {
"type": "git",
Expand All @@ -24,6 +24,8 @@
"lodash.clonedeep": "^3.0.2"
},
"devDependencies": {
"babel": "^5.8.23",
"chai": "^3.3.0",
"husky": "^0.10.1",
"mocha": "^2.3.3",
"standard": "^5.3.1"
Expand Down
26 changes: 26 additions & 0 deletions run-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'
const Mocha = require('mocha')
const fs = require('fs')
const path = require('path')

// Instantiate a Mocha instance.
var mocha = new Mocha()

var testDir = 'test'
require('babel/register')({
ignore: false
})
// Add each .js file to the mocha instance
fs.readdirSync(testDir).filter(function (file) {
// Only keep the .js files
return file.substr(-3) === '.js'
}).forEach(function (file) {
mocha.addFile(path.join(testDir, file))
})

// Run the tests.
mocha.run(function (failures) {
process.on('exit', function () {
process.exit(failures)
})
})
20 changes: 20 additions & 0 deletions test/jspm-hot-reloader.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env node, mocha */
import HotReloader from '../jspm-hot-reloader'
import {expect} from 'chai'
describe('jspm-hot-reloader', function () {
let hr
it('should listen to socket.io and call hotReload on itself, when a change event comes', () => {
hr = new HotReloader('')
hr.on('change', (file) => {
expect(file).to.equal(file)
})
})

it('should revert back the tree if some import during hotReload fails', () => {

})

after(() => {
hr.socket.disconnect()
})
})

0 comments on commit f2eeaaf

Please sign in to comment.