Implements the first specs
TDD yeah !!!
This commit is contained in:
@@ -2,70 +2,78 @@
|
||||
// Generated on Fri Feb 12 2016 12:00:28 GMT+0100 (CET)
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
// 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'],
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'../webapp/js/**/*.js',
|
||||
'../webapp/bower_components/angular*/**/*.js',
|
||||
'specs/**/*.js'
|
||||
],
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'webapp/bower_components/angular/angular.js',
|
||||
'webapp/bower_components/angular-mocks/angular-mocks.js',
|
||||
'webapp/bower_components/angular-route/angular-route.js',
|
||||
'webapp/bower_components/karma-read-json/karma-read-json.js',
|
||||
'webapp/js/**/*.js',
|
||||
'test/specs/**/*.js',
|
||||
{pattern: 'test/data/*.json', watched: true, served:true, included: false}
|
||||
],
|
||||
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
],
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
],
|
||||
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
},
|
||||
// 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'],
|
||||
// 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,
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
// 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,
|
||||
// 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,
|
||||
// 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', 'Safari', 'Firefox'],
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: [
|
||||
'Chrome'
|
||||
// 'Safari',
|
||||
// 'Firefox'
|
||||
],
|
||||
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false,
|
||||
// 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
|
||||
})
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,63 @@
|
||||
describe('Service: albumService', function() {
|
||||
|
||||
beforeEach(module('satbd.satellite.bar.services'));
|
||||
|
||||
var $httpBackend,albumService;
|
||||
|
||||
var albums = readJSON('test/data/albums.json')
|
||||
var albumsByIDs = {};
|
||||
for ( var i = 0; i < albums.length; i++) {
|
||||
albumsByIDs[albums[i].ID] = albums;
|
||||
}
|
||||
|
||||
beforeEach(inject(function($injector) {
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
for ( var i = 0; i < albums.length; i++) {
|
||||
$httpBackend.when('GET','/api/albums/'+ albums[i].ID).respond(200,albums[i]);
|
||||
}
|
||||
$httpBackend.when('GET','/api/albums/1234').respond(404, 'Error not found');
|
||||
albumService = $injector.get('albumService');
|
||||
}));
|
||||
|
||||
|
||||
|
||||
it('can get an album data', function() {
|
||||
for ( var i = 0; i < albums.length; i++) {
|
||||
var album, err;
|
||||
albumService.get(albums[i].ID).then(function(data) {
|
||||
album = data;
|
||||
}).catch( function() {
|
||||
err = 'Could not get album';
|
||||
});
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(album.ID).toBe(albums[i].ID);
|
||||
expect(err).toBe(undefined);
|
||||
}
|
||||
|
||||
var album = undefined , err = undefined;
|
||||
albumService.get(1234).then(function(data) {
|
||||
album = data;
|
||||
}).catch( function() {
|
||||
err = 'Could not get album';
|
||||
});
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(album).toBe(undefined)
|
||||
expect(err).toBe('Could not get album');
|
||||
});
|
||||
|
||||
it('renames non-utf-8 field to utf-8', function() {
|
||||
for ( var i = 0; i < albums.length; i++) {
|
||||
var album;
|
||||
albumService.get(albums[i].ID)
|
||||
.then(function(data) {
|
||||
album = data;
|
||||
})
|
||||
$httpBackend.flush();
|
||||
expect(album.serie).toBe(albums[i].série);
|
||||
expect(album.série).toBe(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user