Skip to content

Commit

Permalink
testing tests framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlin committed Jun 28, 2019
1 parent a39f947 commit 7fb20c2
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 10 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ node_js: # note: node v12+ doesn't work with gulp 3
- 8
- 7
- 6
before_script:
install:
- npm install -g gulp-cli
script: gulp build
- npm install -g mocha
- npm install phantomjs -g
- npm install -g mocha-phantomjs
before_script:
— mocha —version
# - mocha -u tdd -—reporter spec
— phantomjs —version
 — mocha-phantomjs —version
- mocha-phantomjs test/spec/index.html
script:
- gulp build
138 changes: 137 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
"gulp-chrome-manifest": "0.0.13",
"gulp-clean-css": "^2.0.3",
"gulp-eslint": "^2.0.0",
"gulp-htmlmin": "^2.0.0",
"gulp-if": "^2.0.0",
"gulp-imagemin": "^3.0.0",
"gulp-livereload": "^3.8.1",
"gulp-load-plugins": "^1.2.0",
"gulp-htmlmin": "^2.0.0",
"gulp-size": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.3",
"gulp-useref": "^3.0.8",
"gulp-zip": "^3.2.0",
"mocha": "^6.1.4",
"run-sequence": "^1.1.5",
"sinon-chrome": "^3.0.1",
"wiredep": "^4.0.0"
},
"dependencies": {
}
"dependencies": {}
}
10 changes: 9 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@
var should = chai.should();
</script>
<!-- include source files here... -->
<script src="spec/sinon-chrome.min.js"></script>
<script src="../../app/vendor/scripts/jquery-2.1.1-simplified.min.js"></script>
<script src="../../app/vendor/scripts/moment-with-locales.min.js"></script>
<script src="../../app/scripts/constants.js"></script>
<script src="../../app/scripts/ate.js"></script>
<!-- include spec files here... -->
<script src="spec/test.js"></script>
<script>
if (navigator.userAgent.indexOf('PhantomJS') === -1) {
if (navigator.userAgent.indexOf('PhantomJS') === -1
|| !window.mochaPhantomJS) {
mocha.run();
} else {
mochaPhantomJS.run();
}
</script>
</body>
Expand Down
61 changes: 61 additions & 0 deletions test/spec/sinon-chrome.min.js

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions test/spec/test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
// Browser-based tests

(function () {
'use strict';

describe('Give it some context', function () {
describe('maybe a bit more context here', function () {
it('should run here few assertions', function () {
console.log('Browser-based Tests');

describe('initialization', function() {
describe('jquery init', function() {
it('should be available as a function', function() {
expect(typeof window.jQuery).to.equal('function');
});
});
describe('moment init', function() {
it('should be available as a function', function() {
expect(typeof window.moment).to.equal('function');
});
});
describe('constants init', function() {
it('should have PROD chrome extension ID', function() {
expect(APP_ID_PRODUCTION).to.equal('iibninhmiggehlcdolcilmhacighjamp');
});
});
});

})();
28 changes: 28 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Nodejs tests

(function () {
'use strict';

console.log('Nodejs Tests');

var chai = require('chai')
var assert = chai.assert;
var expect = chai.expect;
var should = chai.should();

// Mock out chrome APIs
const chrome = require('sinon-chrome');

describe('Background.js', function() {

// Mock out Chrome's extension APIs
before(function () { global.chrome = chrome; });

describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});

})();

0 comments on commit 7fb20c2

Please sign in to comment.