Skip to content

Commit

Permalink
Test the types
Browse files Browse the repository at this point in the history
  • Loading branch information
kabirbaidhya committed Oct 28, 2019
1 parent e39f015 commit fcc6d08
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,41 @@ function testParseWithoutProcessing() {

const parsedTemplateWithoutOptions: hbs.AST.Program = Handlebars.parseWithoutProcessing('<p>Hello, my name is {{name}}.</p>');
}

// Test exception constructor with just message.
try {
const exp = new Handlebars.Exception('Just a test message.');

// Assert
exp.message === 'Just a test message.' ? 'Passed': 'Failed';

throw exp;
} catch(e) {
// Catch exception here.
}

try {
const node: Handlebars.ExceptionNode = {
loc: {
start: {line: 1, column: 5},
end: {line: 10, column: 2}
}
};

const exp = new Handlebars.Exception('Just a test message.', node);

// Assert
exp.message === 'Just a test message.' ? 'Passed': 'Failed';
exp.lineNumber === 1 ? 'Passed': 'Failed';
exp.column === 5 ? 'Passed': 'Failed';
exp.endLineNumber === 10 ? 'Passed': 'Failed';
exp.endColumn === 2 ? 'Passed': 'Failed';
exp.description; // Could be a string value.
exp.name; // Could be a string value.
exp.fileName; // Could be a string value.
exp.stack; // Could be a string value if not undefined.

throw exp;
} catch(e) {
// Catch exception here.
}

0 comments on commit fcc6d08

Please sign in to comment.