forked from ariatemplates/hashspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: throw a descriptive error when an undefined attribute is used fo…
…r a component Fixes ariatemplates#253
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var klass=require("hsp/klass"), | ||
ht=require("hsp/utils/hashtester"); | ||
|
||
var FooNoAttrsCtrl=klass({ | ||
}); | ||
|
||
var FooEmptyAttrsCtrl=klass({ | ||
attributes: { | ||
} | ||
}); | ||
|
||
{template fooNoAttrs using ctrl:FooNoAttrsCtrl} | ||
<div>foo</div> | ||
{/template} | ||
|
||
{template fooEmptyAttrs using ctrl:FooEmptyAttrsCtrl} | ||
<div>foo</div> | ||
{/template} | ||
|
||
{template test1} | ||
<#fooNoAttrs foo="bar"></#fooNoAttrs> | ||
{/template} | ||
|
||
{template test2} | ||
<#fooEmptyAttrs foo="bar"></#fooEmptyAttrs> | ||
{/template} | ||
|
||
describe('error reporting for custom components', function() { | ||
|
||
var h; | ||
beforeEach(function() { | ||
h=ht.newTestContext(); | ||
}); | ||
|
||
it('attribute used for a component without attributes', function() { | ||
expect(function() { | ||
test1().render(h.container); | ||
}).to.throwException(/The attribute "foo" was used but the component doesn't define this attribute./); | ||
}); | ||
|
||
it('attribute used for a component without attributes', function() { | ||
expect(function() { | ||
test2().render(h.container); | ||
} ).to.throwException(/The attribute "foo" was used but the component doesn't define this attribute./); | ||
}); | ||
|
||
afterEach(function(){ | ||
h.$dispose(); | ||
}); | ||
|
||
}); |