-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #633 from BitLucid/js_unit_testing
Js unit testing
- Loading branch information
Showing
11 changed files
with
337 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,5 @@ Icon | |
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
node_modules/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; // Strict checking. | ||
describe('Array', function() { | ||
describe('#indexOf()', function() { | ||
it('should return -1 when the value is not present', function() { | ||
var res = [1,2,3].indexOf(5); | ||
expect(res).toEqual(-1); | ||
expect([1,2,3].indexOf(0)).toEqual(-1); | ||
expect([1,2,3].indexOf(3)).toEqual(2); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; // Strict checking. | ||
describe('Debug', function() { | ||
describe('dump()', function() { | ||
it('should return formatted var text of arguments', function() { | ||
var arr = {jim:'bob'}; | ||
var res = dump(arr, 0); | ||
expect(res).not.toEqual(''); | ||
}); | ||
}); | ||
}); | ||
describe('Echo', function() { | ||
describe('echo()', function() { | ||
it('should just return a parameter passed in', function() { | ||
var res = testEcho('something'); | ||
expect(res).toEqual('something'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Hello world', function(){ | ||
it('says hello', function(){ | ||
expect(helloWorld()).toEqual('hello world'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"use strict"; // Strict checking. | ||
|
||
|
||
/*require(['jquery'], function($) { | ||
$('body').css('background-color', 'green'); | ||
});*/ | ||
/*requirejs(["nw.js"], function(NW) { | ||
//Called when nw.js is included | ||
//This function is called when scripts/helper/util.js is loaded. | ||
//If util.js calls define(), then this function is not fired until | ||
//util's dependencies have loaded, and the util argument will hold | ||
//the module value for "helper/util". | ||
});*/ | ||
|
||
describe('NW', function() { | ||
describe('NW App testing context', function() { | ||
var app = NW; | ||
var env = environment; | ||
beforeEach(function() { | ||
}); | ||
|
||
afterEach(function() { | ||
}); | ||
|
||
it('should be able to see var defined in nw.js', function() { | ||
expect(env).toBeDefined(); | ||
expect(env).toMatch(/NW.+context/); | ||
}); | ||
it('should be able to get the NW object', function() { | ||
expect(app).toBeDefined(); | ||
}); | ||
it('should have access to the location checks', function() { | ||
expect(g_isIndex).toBeDefined(); | ||
expect(g_isRoot).toBeDefined(); | ||
expect(g_isSubpage).toBeDefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Karma configuration | ||
// Generated on Sun Mar 20 2016 07:47:48 GMT-0400 (EDT) | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '../..', | ||
|
||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['jasmine', 'requirejs'], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'test-main.js', | ||
'deploy/www/js/jquery.min.js', | ||
'deploy/www/js/jquery.timeago.js', | ||
'deploy/www/js/nw.js', | ||
'deploy/www/js/debug.js', | ||
'deploy/www/js/passwords.js', | ||
'deploy/www/js/talk.js', | ||
'deploy/www/js/casino.js', | ||
'deploy/www/js/disagreement.js', | ||
{pattern: 'deploy/www/js/*.js', included: false}, | ||
{pattern: 'deploy/tests/js/*Spec.js', included: false} | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
'deploy/www/js/jquery.timeago.js', | ||
'deploy/www/js/jquery.linkify.js', | ||
'deploy/www/js/jquery.linkify.min.js', | ||
'deploy/www/js/casino.js', | ||
'deploy/www/js/disagreement.js', | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress'], | ||
|
||
|
||
// web server port | ||
port: 9876, | ||
|
||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
|
||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['Chrome', 'PhantomJS'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false, | ||
|
||
// Concurrency level | ||
// how many browser should be started simultaneous | ||
concurrency: Infinity | ||
}); | ||
//console.log(config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.