Skip to content

Commit

Permalink
Add one more unit test and some minor fixes
Browse files Browse the repository at this point in the history
This is part of the effort to create an official TypeScript compiler:
Urigo/angular2-meteor#89
Urigo/angular2-meteor#90
Urigo/angular2-meteor#102
  • Loading branch information
barbatus committed Feb 15, 2016
1 parent c9e5322 commit e81585d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ var validOptions = {
"moduleName": "String",
"typings": "Array"
};
var validOptionsMsg = "Valid options are" +
"compilerOptions, filePath, moduleName, and typings";
var validOptionsMsg = "Valid options are " +
"compilerOptions, filePath, moduleName, and typings.";

function checkType(option, optionName) {
if (! option) return true;
Expand All @@ -61,7 +61,7 @@ function validateAndConvertOptions(options) {
for (var option in options) {
if (options.hasOwnProperty(option)) {
if (validOptions[option] === undefined) {
throw new Error("Unknown option: " + option + "." +
throw new Error("Unknown option: " + option + ".\n" +
validOptionsMsg);
}

Expand All @@ -79,6 +79,8 @@ function validateAndConvertOptions(options) {
}
}

exports.validateAndConvertOptions = validateAndConvertOptions;

exports.getDefaultOptions = function getDefaultOptions() {
return {
compilerOptions: getDefaultCompilerOptions()
Expand Down
4 changes: 2 additions & 2 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ exports.presetCompilerOptions = presetCompilerOptions;
// Default compiler options.
function getDefaultCompilerOptions() {
return {
module : ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES3,
module : "commonjs",
target: "ES3",
sourceMap: true,
noResolve: false,
diagnostics: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "meteor-typescript",
"author": "@barbatus",
"version": "0.5.5",
"version": "0.5.7",
"license": "MIT",
"description": "TypeScript wrapper package for use with Meteor",
"keywords": [
Expand Down
11 changes: 11 additions & 0 deletions tests/ts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ describe("meteor-typescript -> ", function() {
};
expect(test).toThrow();
});

it("should validate options", function() {
var test = function() {
meteorTS.validateAndConvertOptions({
wrong: true
});
};

expect(test).toThrow(new Error("Unknown option: wrong.\n" +
"Valid options are compilerOptions, filePath, moduleName, and typings."));
});
});

describe("testing diagnostics and typings -> ", function() {
Expand Down

0 comments on commit e81585d

Please sign in to comment.