Permalink
Browse files

added first unit test

  • Loading branch information...
1 parent e3f0d6a commit a2f99e4e15a9d59210c45b8177628d8efc7387c0 @christian-bromann christian-bromann committed Jan 19, 2015
Showing with 121 additions and 7 deletions.
  1. +9 −0 .travis.yml
  2. +9 −7 package.json
  3. +9 −0 test/bootstrap.js
  4. +5 −0 test/mocha.opts
  5. +89 −0 test/spec/unit.js
View
@@ -0,0 +1,9 @@
+notifications:
+ email: false
+
+language: node_js
+
+node_js:
+ - '0.10'
+
+script: "npm test"
View
@@ -2,10 +2,9 @@
"name": "webdriverrtc",
"version": "0.0.0",
"description": "WebRTC testing tool for WebdriverIO",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
+ "author": "Christian Bromann <christian@saucelabs.com>",
+ "homepage": "https://github.com/webdriverio/webdriverrtc",
+ "license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/webdriverio/webdriverrtc"
@@ -15,13 +14,16 @@
"webdriver",
"webrtc"
],
- "author": "Christian Bromann <christian@saucelabs.com>",
- "license": "MIT",
"bugs": {
"url": "https://github.com/webdriverio/webdriverrtc/issues"
},
- "homepage": "https://github.com/webdriverio/webdriverrtc",
+ "main": "index.js",
+ "scripts": {
+ "test": "./node_modules/.bin/mocha"
+ },
"devDependencies": {
+ "chai": "^1.10.0",
+ "mocha": "^2.1.0",
"webdriverio": "git://github.com/webdriverio/webdriverio#v2.5.0rc1"
}
}
View
@@ -0,0 +1,9 @@
+/**
+ * require dependencies
+ */
+WebdriverIO = require('webdriverio');
+WebdriverRTC = require('../');
+should = require('chai').should();
+expect = require('chai').expect;
+capabilities = {logLevel: 'silent',desiredCapabilities:{browserName: 'phantomjs'}};
+testurl = 'http://localhost:8080/test/site/index.html';
View
@@ -0,0 +1,5 @@
+test/bootstrap.js
+test/spec/*.js
+
+--timeout 1000000,
+--reporter spec
View
@@ -0,0 +1,89 @@
+var calcResult = require('../../lib/calcResult');
+
+describe('calcResult', function() {
+
+ var result = {
+ attr1: 0,
+ attr2: 0,
+ attr3: {
+ attr1: 0,
+ attr2: 0,
+ attr3: {
+ attr1: {
+ attr1: 0
+ }
+ }
+ }
+ }
+
+ var exampleResults = [{
+ attr1: 1,
+ attr2: 2,
+ attr3: {
+ attr1: 3,
+ attr2: 4,
+ attr3: {
+ attr1: {
+ attr1: 5
+ }
+ }
+ }
+ },{
+ attr1: 1,
+ attr2: 2,
+ attr3: {
+ attr1: 3,
+ attr2: 4,
+ attr3: {
+ attr1: {
+ attr1: 5
+ }
+ }
+ }
+ },{
+ attr1: 1,
+ attr2: 2,
+ attr3: {
+ attr1: 3,
+ attr2: 4,
+ attr3: {
+ attr1: {
+ attr1: 5
+ }
+ }
+ }
+ },{
+ attr1: 1,
+ attr2: 2,
+ attr3: {
+ attr1: 3,
+ attr2: 4,
+ attr3: {
+ attr1: {
+ attr1: 5
+ }
+ }
+ }
+ }];
+
+ it('should add to result', function() {
+ calcResult['+'](exampleResults, result);
+
+ result.attr1.should.be.equal(4);
+ result.attr2.should.be.equal(8);
+ result.attr3.attr1.should.be.equal(12);
+ result.attr3.attr2.should.be.equal(16);
+ result.attr3.attr3.attr1.attr1.should.be.equal(20);
+ });
+
+ it('should divide the result', function() {
+ calcResult['/'](result, exampleResults.length);
+
+ result.attr1.should.be.equal(1);
+ result.attr2.should.be.equal(2);
+ result.attr3.attr1.should.be.equal(3);
+ result.attr3.attr2.should.be.equal(4);
+ result.attr3.attr3.attr1.attr1.should.be.equal(5);
+ });
+
+})

0 comments on commit a2f99e4

Please sign in to comment.