Skip to content

Commit

Permalink
test(e2e): add a test for dojo adapter
Browse files Browse the repository at this point in the history
Closes #328
  • Loading branch information
garcimouche authored and vojtajina committed Aug 1, 2013
1 parent 99c72c9 commit f499f7b
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"karma-ng-scenario": "*",
"karma-coffee-preprocessor": "*",
"karma-html2js-preprocessor": "*",
"karma-dojo":"*",
"semver": "~1.1.4",
"grunt-contrib-watch": "~0.5.0"
},
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/dojo/dependency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define(function() {
// return the module value
return function (a, b) {
return a + b;
};
}
);
64 changes: 64 additions & 0 deletions test/e2e/dojo/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',

frameworks: ['jasmine', 'dojo'],

// list of files / patterns to load in the browser
files: [
'main.js',

// all the sources, tests
{pattern: '*.js', included: false}
],


// test results reporter to use
// possible values: dots || progress
reporters: ['dots'],


// web server port
port: 9876,


// cli runner port
runnerPort: 9100,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari
// - PhantomJS
browsers: [process.env.TRAVIS ? 'Firefox' : 'Chrome'],


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,

plugins: [
'karma-dojo',
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher'
]
});
};
32 changes: 32 additions & 0 deletions test/e2e/dojo/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var allTestFiles = [];
var TEST_REGEXP = /test.*\.js$/;

Object.keys(window.__karma__.files).forEach(function(file) {
if (TEST_REGEXP.test(file)) {
allTestFiles.push(file);
}
});

var dojoConfig = {
packages: [
{ name:"local" ,location:"/base"},
{ name: "dojo", location: "http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo" },
{ name: "dojox", location: "http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojox" }
],
asynch: true
};


/**
* This function must be defined and is called back by the dojo adapter
* @returns {string} a list of dojo spec/test modules to register with your testing framework
*/
window.__karma__.dojoStart = function(){
return allTestFiles;
}






18 changes: 18 additions & 0 deletions test/e2e/dojo/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define(['local/dependency','dojo/_base/lang'], function(dep,lang) {

// jasmine
describe('something', function() {
it('should pass', function() {
expect(true).toBe(true);
});

it('should sum', function() {
expect(dep(1, 2)).toBe(3);
});

it('should trim using a dojo AMD module',function(){
expect(lang.trim(" len4 ").length).toEqual(4);
});

});
});

0 comments on commit f499f7b

Please sign in to comment.