-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug registering component with static
view.is
prop but no `view…
….file` prop
- Loading branch information
1 parent
8eedad2
commit 2449b82
Showing
2 changed files
with
59 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,58 @@ | ||
var expect = require('chai').expect; | ||
var pathLib = require('node:path'); | ||
var domTestRunner = require('../../test-utils/domTestRunner'); | ||
|
||
describe('components', function() { | ||
var runner = domTestRunner.install(); | ||
|
||
describe('app.component registration', function() { | ||
describe('passing just component class', function() { | ||
describe('with static view prop', function() { | ||
it('external view file', function() { | ||
var harness = runner.createHarness(); | ||
|
||
function SimpleBox() {} | ||
SimpleBox.view = { | ||
is: 'simple-box', | ||
// Static `view.file` property, defining path of view file | ||
file: pathLib.resolve(__dirname, '../fixtures/simple-box') | ||
}; | ||
harness.app.component(SimpleBox); | ||
|
||
harness.setup('<view is="simple-box"/>'); | ||
expect(harness.renderHtml().html).to.equal('<div class="simple-box"></div>'); | ||
}); | ||
|
||
it('inlined view.source', function() { | ||
var harness = runner.createHarness(); | ||
|
||
function SimpleBox() {} | ||
SimpleBox.view = { | ||
is: 'simple-box', | ||
source: '<index:><div>Inlined source</div>' | ||
}; | ||
harness.app.component(SimpleBox); | ||
|
||
harness.setup('<view is="simple-box"/>'); | ||
expect(harness.renderHtml().html).to.equal('<div>Inlined source</div>'); | ||
}); | ||
|
||
it('inferred view file from view name', function() { | ||
var harness = runner.createHarness(); | ||
|
||
// Pre-load view with same name as the component's static `view.is` | ||
harness.app.loadViews(pathLib.resolve(__dirname, '../fixtures/simple-box'), 'simple-box'); | ||
|
||
function SimpleBox() {} | ||
SimpleBox.view = { | ||
is: 'simple-box' | ||
}; | ||
harness.app.component(SimpleBox); | ||
|
||
harness.setup('<view is="simple-box"/>'); | ||
expect(harness.renderHtml().html).to.equal('<div class="simple-box"></div>'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |