Created
October 26, 2013 11:07
-
-
Save andreareginato/7168181 to your computer and use it in GitHub Desktop.
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
// Karma configuration | |
// http://karma-runner.github.io/0.10/config/configuration-file.html | |
module.exports = function(config) { | |
config.set({ | |
// base path, that will be used to resolve files and exclude | |
basePath: '', | |
// testing framework to use (jasmine/mocha/qunit/...) | |
frameworks: ['jasmine'], | |
// list of files / patterns to load in the browser | |
files: [ | |
'app/bower_components/jquery/jquery.js', | |
'app/bower_components/angular/angular.js', | |
'app/bower_components/angular-cookies/angular-cookies.js', | |
'app/bower_components/angular-resource/angular-resource.js', | |
'app/bower_components/angular-mocks/angular-mocks.js', | |
'app/bower_components/timecop/*.js', | |
'app/scripts/*.js', | |
'app/scripts/**/*.js', | |
'app/views/**/*.html', | |
'test/spec/services/**/*.js', | |
'test/spec/directives/**/*.js' | |
], | |
// list of files / patterns to exclude | |
exclude: [], | |
// web server port | |
port: 8080, | |
// 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 (only Mac) | |
// - PhantomJS | |
// - IE (only Windows) | |
browsers: ['PhantomJS'], | |
// Continuous Integration mode | |
// if true, it capture browsers, run tests and exit | |
singleRun: false, | |
// Preprocessor for converting HTML files to AngularJS templates | |
preprocessors: { 'app/views/**/*.html': 'html2js' }, | |
// creates a single module containing all templates (cached), so that | |
// you can load them all with module('templates') using the cache e not | |
// making the request. | |
ngHtml2JsPreprocessor: { | |
moduleName: 'templates' | |
}, | |
}); | |
}; |
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
describe('login', function() { | |
var $location, $cookies, $httpBackend | |
beforeEach(inject(function($injector) { $location = $injector.get('$location') })); | |
beforeEach(inject(function($injector) { $cookies = $injector.get('$cookies') })); | |
beforeEach(inject(function($injector) { $httpBackend = $injector.get('$httpBackend') })); | |
// load directive | |
beforeEach(module('login')); | |
// template caching | |
beforeEach(angular.mock.module('templates')); | |
// directive compilation | |
var compile = function($rootScope, $compile) { | |
scope = $rootScope; | |
$compile(element)(scope); | |
scope.$digest(); | |
} | |
describe('when logged in', function() { | |
// mock the API request | |
beforeEach(function() { | |
$httpBackend.whenGET('http://example.com/me', headers).respond({ id: 1 }); | |
}); | |
beforeEach(inject(function($rootScope, $compile) { | |
compile($rootScope, $compile); | |
})); | |
it('shows the link "Logout #{profile.email}"', inject(function(Profile) { | |
$httpBackend.flush(); | |
result = element.find('.logout').text(); | |
expect(result).toBe('Logout Alice Wonderland'); | |
})); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment