Commit b55d0571 authored by Grand Francois's avatar Grand Francois
Browse files

Mise au point de la base des tests unitaires

Showing with 54 additions and 105 deletions
+54 -105
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# compiled output # compiled output
/dist /dist
/build
/tmp /tmp
/out-tsc /out-tsc
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
npm-debug.log npm-debug.log
testem.log testem.log
/typings /typings
Makefile
# e2e # e2e
/e2e/*.js /e2e/*.js
......
...@@ -5,17 +5,19 @@ module.exports = function (config) { ...@@ -5,17 +5,19 @@ module.exports = function (config) {
config.set({ config.set({
// base path that will be used to resolve all patterns (eg. files, exclude) // base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '', basePath: './',
// frameworks to use // frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'karma-typescript'], frameworks: ['jasmine', 'requirejs'],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
{ pattern: 'dist/out-tsc/**/*.spec.js', included: false } { pattern: 'src/**/*.ts', included: false },
{ pattern: 'spec/**/*.ts', included: false },
'spec/test-main.js'
], ],
...@@ -27,21 +29,24 @@ module.exports = function (config) { ...@@ -27,21 +29,24 @@ module.exports = function (config) {
// preprocess matching files before serving them to the browser // preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: { preprocessors: {
'src/**/*.spec.ts': ['karma-typescript'] '+(src|spec)**/*.ts': ['typescript']
}, },
typescriptPreprocessor: {
options: {
// https://github.com/Microsoft/TypeScript/blob/b0584b58fa07ee8c06e6d6f0f1bce2d4c37c7640/lib/typescript.d.ts#L1573
// enum ScriptTarget { ES3 = 0, ES5 = 1, ES6 = 2, ES2015 = 2, Latest = 2 }
target: 1,
// https://github.com/Microsoft/TypeScript/blob/b0584b58fa07ee8c06e6d6f0f1bce2d4c37c7640/lib/typescript.d.ts#L1544
// enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, UMD = 3, System = 4, ES6 = 5, ES2015 = 5 }
module: 2
}
},
// test results reporter to use // test results reporter to use
// possible values: 'dots', 'progress' // possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter // available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'karma-typescript'], reporters: ['progress', 'kjhtml'],
// https://github.com/monounity/karma-typescript/blob/master/cookbook.md#user-content-importing-es2015-aka-es6-modules
karmaTypescriptConfig: {
bundlerOptions: {
transforms: [require("karma-typescript-es6-transform")()]
}
},
// web server port // web server port
......
{ {
"name": "jalhyd", "name": "JaLHyd",
"version": "0.0.1", "version": "1.0.0",
"license": "MIT", "author": "DD",
"license": "ISC"
"description": "Javascript Library for Hydraulics",
"dependencies": {},
"devDependencies": {
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-chrome-launcher": "^2.0.0",
"karma-requirejs": "^1.1.0",
"karma-typescript-preprocessor": "^0.3.0",
"requirejs": "^2.3.2",
"typescript": "^2.0.3",
"tslint": "^3.15.1"
},
"scripts": { "scripts": {
"build": "tsc --p src/tsconfig.app.json", "build": "./node_modules/typescript/bin/tsc --p src/tsconfig.app.json",
"test": "./node_modules/karma/bin/karma start", "test": "./node_modules/typescript/bin/tsc --p spec/tsconfig.spec.json && ./node_modules/karma/bin/karma start",
"lint": "./node_modules/tslint/bin/tslint", "lint": "./node_modules/tslint/bin/tslint",
"viz": "tsviz -recursive src/ jalhyd_class_diagram.png" "viz": "tsviz -recursive src/ jalhyd_class_diagram.png"
}, },
"private": true,
"dependencies": {},
"devDependencies": {
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.1.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-typescript": "^3.0.1",
"karma-typescript-es6-transform": "^1.0.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
} }
import { Nub, Result } from "base";
class NubTest extends Nub {
Equation(): Result {
let res: Result = new Result();
res.varCalc = this.v["A"] + this.v["B"];
return res;
}
}
let nub = new NubTest({ "A": 1, "B": 2, "C": null });
let res = new Result;
describe('Class Nub: ', () => {
beforeEach(() => {
nub.sVarsEq = ["C"];
res.varCalc = 3;
});
describe('Calc(): ', () => {
it('should return a result', () => {
expect(nub.Calc("C")).toBe(res);
});
});
});
import { Nub, Result, IParametres } from "base"; import { Nub, Result, IParametres } from "./base";
interface IParamLechaptCalmon extends IParametres { interface IParamLechaptCalmon extends IParametres {
......
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [] "types": []
}, },
"exclude": [ "include": [
"test.ts", "../src/**/*.ts"
"**/*.spec.ts" ],
] "exclude": []
} }
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es5",
"baseUrl": "",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
{ {
"compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5", "target": "es5",
"typeRoots": [ "module": "commonjs",
"node_modules/@types" "outDir": "./build",
], "noImplicitAny": false,
"lib": [ "sourceMap": true
"es2016", },
"dom" "exclude": [
] "node_modules"
} ]
} }
\ No newline at end of file
...@@ -127,4 +127,4 @@ ...@@ -127,4 +127,4 @@
"templates-use-public": true, "templates-use-public": true,
"invoke-injectable": true "invoke-injectable": true
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment