Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-- #20

Closed
wants to merge 3 commits into from
Closed

-- #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"browser": true,
"globalstrict": true,
"es3": true,
"globals": {}
}
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "0.10"
notifications:
email:
recipients:
- [email protected]
on_failure: change
on_success: never
5 changes: 2 additions & 3 deletions Imager.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
gif.setAttribute('data-src', element.getAttribute('data-src'));

element.parentNode.replaceChild(gif, element);
}
};

Imager.prototype.changeDivsToEmptyImages = function(){
var divs = this.divs,
Expand Down Expand Up @@ -152,8 +152,7 @@
};

Imager.prototype.checkImagesNeedReplacing = function(){
var self = this,
images = $(this.className),
var images = $(this.className),
i = images.length,
currentImage;

Expand Down
69 changes: 69 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Karma configuration
// Generated on Tue Oct 29 2013 11:45:20 GMT+0000 (GMT)

module.exports = function(config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath: '',


// frameworks to use
frameworks: ['mocha', 'chai'],


// list of files / patterns to load in the browser
files: [
'Imager.js',
'test/unit/**/*.js'
],


// list of files to exclude
exclude: [

],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
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, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['PhantomJS'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Imager.js is an alternative solution to the issue of how to handle responsive image loading, created by developers at BBC News.",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jshint Imager.js && karma start --single-run",
"test-watch": "karma start"
},
"repository": {
"type": "git",
Expand All @@ -25,6 +26,20 @@
"gitHead": "8d192cf0224a705e463b4dca18041168d491a6e9",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-responsive-images": "0.0.3"
"grunt-responsive-images": "0.0.3",
"karma-chai": "0.0.2",
"karma-mocha": "~0.1.0",
"chai": "~1.8.1",
"mocha": "~1.13.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3",
"karma-requirejs": "~0.1.0",
"karma-coffee-preprocessor": "~0.1.0",
"karma": "~0.10.4",
"jshint": "~2.3.0"
}
}
19 changes: 19 additions & 0 deletions test/unit/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

describe('Imager.js', function(){
describe('constructor', function(){

it('should initialise without arguments', function(done){
var imgr = new Imager();

setTimeout(function(){
expect(imgr.initialized).to.be.true;
expect(imgr.scrolled).to.be.false;
expect(imgr.cache).to.be.empty;

done();
}, 100);
});

});
});