Skip to content

Commit

Permalink
include more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
umakantp committed May 27, 2021
1 parent 024cd90 commit a24791c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
17 changes: 17 additions & 0 deletions test/build-in-functions/include-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,22 @@ define(['jSmart'], function (jSmart) {
t = new jSmart(tpl)
expect(t.fetch()).toBe(output)
})

it('test include inside include', function () {
jSmart.prototype.getTemplate = function (name) {
if (name === 'rchild.tpl') {
return 'include1-{include file="rchild2.tpl"}-include1'
}
if (name === 'rchild2.tpl') {
return 'deep-include'
}
}

tpl = 'main-{include file="rchild.tpl"}-main'

output = 'main-include1-deep-include-include1-main'
t = new jSmart(tpl)
expect(t.fetch()).toBe(output)
})
})
})
12 changes: 11 additions & 1 deletion test/conditions-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@ define(['jSmart', 'text!./templates/if.tpl', 'text!./output/if.tpl'], function (
tpl += '{else}'
tpl += 'and it works'
tpl += '{/if}'
tpl += '|'
tpl += '{if $x = 5}'
tpl += '--{$x}--'
tpl += '{/if}'
tpl += '|'
tpl += '{if $x = 0}'
tpl += 'blank'
tpl += '{elseif $y = 6}'
tpl += '--{$y}--'
tpl += '{/if}'

var output = 'it works|yo works|and it works'
var output = 'it works|yo works|and it works|--5--|--6--'

var t = new jSmart(tpl)

Expand Down

0 comments on commit a24791c

Please sign in to comment.