Added Initial tests infrastructure

Signed-off-by: boris <boris.karastanev@progress.com>
This commit is contained in:
boris 2017-05-18 14:59:48 +03:00
Родитель 1b8fb65f64
Коммит 02e71c8541
4 изменённых файлов: 54 добавлений и 2 удалений

4
.gitignore поставляемый
Просмотреть файл

@ -72,7 +72,9 @@ references.d.ts
*.js.map
#ignore templates folder
lib/templates/
#ignore xunit.xml
xunit.xml

Просмотреть файл

@ -3,7 +3,9 @@
"version": "0.0.1",
"description": "CLI extension for the NatvieScript CLI",
"main": "lib/bootstrap.js",
"scripts": {},
"scripts": {
"test": "node_modules/.bin/istanbul cover node_modules/mocha/bin/_mocha -- --recursive --reporter spec-xunit-file --require test/test-bootstrap.js --timeout 1000 test/"
},
"repository": {},
"author": "Progress <support@telerik.com>",
"license": "Apache-2.0",

12
test/test-bootstrap.ts Normal file
Просмотреть файл

@ -0,0 +1,12 @@
import { use } from "chai";
const cliGlobal = <ICliGlobal>global;
cliGlobal._ = require("lodash");
cliGlobal.$injector = require("mobile-cli-lib/yok").injector;
use(require("chai-as-promised"));
// Converts the js callstack to typescript
import errors = require("mobile-cli-lib/errors");
errors.installUncaughtExceptionListener();

Просмотреть файл

@ -0,0 +1,36 @@
import {TemplateService} from "../lib/services/template-service"
import {Yok} from "mobile-cli-lib/yok";
const should = require('chai').should();
let testInjector: any;
describe("TemplateService Api", () => {
beforeEach(function () {
testInjector = new Yok();
testInjector.register("templateService", TemplateService);
});
describe("Get template Version", function () {
it("returns a template's version from package.json", function () {
let templateService = new TemplateService(),
version = templateService.getTemplateVersion('template-hello-world-ng');
version.should.be.a("string");
version.should.not.be.an("object");
version.should.not.be.a("number");
version.should.not.be.instanceOf(Error);
});
it("should handle errors gracefully", function () {
let templateService = new TemplateService(),
version = templateService.getTemplateVersion('templateее-hello-world-ng');
version.should.be.instanceOf(Error);
version.should.not.be.a("string");
version.should.not.be.an("object");
version.should.not.be.a("number");
});
});
});