Merge pull request #4033 from furinvader/refactoring/add_karma_ts_preprocessor

Add Karma TypeScript Preprocessor
pull/4036/head
Alex Dik 9 years ago
commit ef6c8cdc44
  1. 34
      frontend/app/components/config/routing.test.ts
  2. 29
      frontend/karma.conf.js
  3. 1
      frontend/package.json
  4. 19
      frontend/tsd.json

@ -26,35 +26,39 @@
// See doc/COPYRIGHT.rdoc for more details.
// ++
describe('Routing', function () {
var $rootScope, $state, mockState = { go: function () {} };
var expect = chai.expect;
beforeEach(angular.mock.module('openproject', function ($provide) {
describe('Routing', () => {
var $rootScope, $state, mockState = {
go: () => {}
};
beforeEach(angular.mock.module('openproject', ($provide) => {
$provide.value('$state', mockState);
}));
beforeEach(inject(function (_$rootScope_) {
beforeEach(inject((_$rootScope_) => {
$rootScope = _$rootScope_;
}));
describe('when the project id is set', function () {
describe('when the project id is set', () => {
var toState, toParams,
spy = sinon.spy(mockState, 'go'),
broadcast = function () {
$rootScope.$broadcast('$stateChangeStart', toState, toParams);
};
beforeEach(function () {
toState = { name: 'work-packages.list' };
toParams = { projectPath: 'my_project', projects: null };
spy = sinon.spy(mockState, 'go'),
broadcast = () => {
$rootScope.$broadcast('$stateChangeStart', toState, toParams);
};
beforeEach(() => {
toState = {name: 'work-packages.list'};
toParams = {projectPath: 'my_project', projects: null};
});
it('sets the projects path segment to "projects" ', function () {
it('sets the projects path segment to "projects" ', () => {
broadcast();
expect(toParams.projects).to.equal('projects');
});
it('routes to the given state', function () {
it('routes to the given state', () => {
broadcast();
expect(spy.withArgs(toState, toParams).called).to.be.true;
});

@ -73,7 +73,8 @@ module.exports = function(config) {
'tests/unit/tests/**/*test.js',
'tests/unit/tests/legacy-tests.js',
'app/components/**/*.test.js'
'app/components/**/*.test.js',
'app/components/**/*.test.ts'
],
@ -88,11 +89,35 @@ module.exports = function(config) {
preprocessors: {
'/templates/**/*.html': ['ng-html2js'],
'../app/assets/javascripts/*.js': ['coverage'],
'app/**/*.js': ['webpack'] // coverage disabled
'app/**/*.js': ['webpack'],
'app/components/**/*.test.ts': ['typescript']
},
ngHtml2JsPreprocessor: {
module: 'openproject.templates'
},
typescriptPreprocessor: {
options: {
sourceMap: false,
target: 'ES5',
module: 'amd',
noImplicitAny: false,
noResolve: true,
removeComments: true,
concatenateOutput: false
},
typings: [
'typings/tsd.d.ts',
'typings/angularjs/angular.d.ts',
'typings/sinon/sinon.d.ts',
'typings/jquery/jquery.d.ts',
'typings/mocha/mocha.d.ts',
'typings/chai/chai.d.ts',
'typings/angularjs/angular-mocks.d.ts'
],
transformPath: function(path) {
return path.replace(/\.ts$/, '.js');
}
},
// test results reporter to use

@ -31,6 +31,7 @@
"karma-mocha": "~0.1.3",
"karma-ng-html2js-preprocessor": "^0.1.2",
"karma-phantomjs-launcher": "~0.1.4",
"karma-typescript-preprocessor": "0.0.21",
"karma-webpack": "^1.5.0",
"mocha": "~1.18.2",
"mocha-jenkins-reporter": "^0.1.2",

@ -6,13 +6,28 @@
"bundle": "typings/tsd.d.ts",
"installed": {
"jquery/jquery.d.ts": {
"commit": "78ba6e41543e5ababbd1dda19797601be3c1f304"
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
},
"angularjs/angular.d.ts": {
"commit": "78ba6e41543e5ababbd1dda19797601be3c1f304"
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
},
"angular-ui-router/angular-ui-router.d.ts": {
"commit": "78ba6e41543e5ababbd1dda19797601be3c1f304"
},
"sinon/sinon.d.ts": {
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
},
"mocha/mocha.d.ts": {
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
},
"assertion-error/assertion-error.d.ts": {
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
},
"chai/chai.d.ts": {
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
},
"angularjs/angular-mocks.d.ts": {
"commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
}
}
}

Loading…
Cancel
Save