Skip to content

Commit

Permalink
test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
scniro committed Apr 27, 2016
1 parent ef82d92 commit e555884
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/fixtures/js/ng.module.doublequotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
angular.module("mod").directive("dir", function () {
return {
scope: {},
templateUrl: "templates/ng.template.basic.html",
link: function (scope, elem, attrs) {
}
}
});
11 changes: 11 additions & 0 deletions test/fixtures/js/ng.module.namedfunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function link() {
console.log('link');
}

angular.module('mod').directive('dir', function () {
return {
scope: {},
templateUrl: 'templates/ng.template.basic.html',
link: link
}
});
36 changes: 36 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,42 @@ describe('tpl2js: engine', function () {
done();
});
});

it('should have no impact on directive file with double quote stynax usage', function (done) {

var expected = 'angular.module("mod").directive("dir", function () {' +
'return {' +
'scope: {},' +
'template: \'<span>basic {{ stuff }}</span>\',' +
'link: function (scope, elem, attrs) {' +
'}' +
'}' +
'});';

tpl2js.inline('/test/fixtures/js/ng.module.doublequotes.js', {}, function (err, actual) {
expect(actual.min()).to.equal(expected.min());
done();
});
});

it('should have no impact on named function link directive', function (done) {
var expected =
'function link(){' +
'console.log(\'link\');' +
'}' +
'angular.module(\'mod\').directive(\'dir\', function () {' +
'return {' +
'scope: {},' +
'template: \'<span>basic {{ stuff }}</span>\',' +
'link: link' +
'}' +
'});';

tpl2js.inline('/test/fixtures/js/ng.module.namedfunction.js', {}, function (err, actual) {
expect(actual.min()).to.equal(expected.min());
done();
});
});
});

describe('tpl2js', function () {
Expand Down

0 comments on commit e555884

Please sign in to comment.