From 07707c34b0400f530ca26bcd97db010f5d21f011 Mon Sep 17 00:00:00 2001 From: vdice Date: Wed, 10 Jun 2015 09:13:14 -0600 Subject: [PATCH] minimal RTCSpec added; sinon still not found? --- karma.conf.coffee | 11 +++++-- package.json | 11 ++++--- test/spec/RTCSpec.coffee | 68 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 test/spec/RTCSpec.coffee diff --git a/karma.conf.coffee b/karma.conf.coffee index b4148d921..df806aa9c 100644 --- a/karma.conf.coffee +++ b/karma.conf.coffee @@ -6,6 +6,7 @@ module.exports = (config) -> frameworks: [ 'mocha' 'commonjs' + 'chai-sinon' 'chai-jquery' 'chai' 'jquery-2.1.0' @@ -15,6 +16,10 @@ module.exports = (config) -> # Modules under test - list specific './modules/**/Settings.js' './modules/**/UIUtil.js' + './modules/**/RTC.js' + + # Module services + './service/**/*.js' # Spec files './test/spec/**/*Spec.coffee' @@ -23,8 +28,8 @@ module.exports = (config) -> exclude: [] preprocessors: - # Modules under test - './modules/**/*.js': [ 'commonjs' ] + # Modules and services under test + './{modules,service}/**/*.js': [ 'commonjs' ] # Spec files './test/spec/**/*Spec.coffee': [ 'coffee', 'commonjs' ] @@ -40,7 +45,7 @@ module.exports = (config) -> bare: true sourceMap: false - reporters: [ 'progress' ] + reporters: [ 'spec' ] port: 9876 colors: true logLevel: config.LOG_INFO diff --git a/package.json b/package.json index d5a3f84ed..661b6d50d 100644 --- a/package.json +++ b/package.json @@ -28,21 +28,24 @@ }, "devDependencies": { "browserify": "^10.2.3", - "chai": "^3.0.0", + "chai": "^2.3.0", "chai-jquery": "^2.0.0", "coffee-script": "^1.9.3", "coffeelint": "^1.10.1", - "jquery": "^2.1.4", - "karma": "^0.12.36", + "karma": "^0.12.35", "karma-chai": "^0.1.0", "karma-chai-jquery": "^1.0.0", + "karma-chai-sinon": "^0.1.5", "karma-coffee-preprocessor": "^0.2.1", "karma-commonjs-plus": "^1.0.0", "karma-jquery": "^0.1.0", "karma-mocha": "^0.1.10", "karma-phantomjs-launcher": "^0.2.0", + "karma-spec-reporter": "0.0.19", "mocha": "^2.2.5", - "phantomjs": "^1.9.17" + "phantomjs": "^1.9.17", + "sinon": "^1.14.1", + "sinon-chai": "^2.7.0" }, "license": "MIT" } diff --git a/test/spec/RTCSpec.coffee b/test/spec/RTCSpec.coffee new file mode 100644 index 000000000..b6e7293ca --- /dev/null +++ b/test/spec/RTCSpec.coffee @@ -0,0 +1,68 @@ +'use strict' + +# Default required globals +global.URL = true + +mockAPP = (type) -> + switch type + when 'CLEAR' + delete global.APP + + else + global.APP = + xmpp: + myJid: -> 'myJid' + +describe 'RTC', -> + + sandbox = undefined + RTC = undefined + mock = + events: undefined + + before -> + sandbox = sinon.sandbox.create() + + mock.events = sandbox.stub() +# EventEmitter: -> +# on: sandbox.stub() + + afterEach -> + sandbox.restore() + + RTC = require('../../modules/RTC/RTC.js', { + 'events': mock.events + './RTCUtils.js': -> + './LocalStream.js': -> + './DataChannels': -> + './MediaStream.js': -> + '../../service/desktopsharing/DesktopSharingEventTypes': -> + '../../service/RTC/MediaStreamTypes': -> + '../../service/RTC/StreamEventTypes.js': -> + '../../service/RTC/RTCEvents.js': -> + '../../service/xmpp/XMPPEvents': -> + '../../service/UI/UIEvents': -> + }) + + describe 'init', -> + + props = + rtcUtils: null + devices: + audio: true + video: true + localStreams: [] + remoteStreams: {} + localAudio: null + localVideo: null + + afterEach -> + mockAPP('CLEAR') + + it 'should init', -> + RTC.should.have.deep.property prop for prop of props + + describe 'addStreamListener', -> + + it 'should invoke eventEmitter.on', -> + \ No newline at end of file