-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new API that requires much less "magical wrapping".
Thanks to turbo87 for working on a very similar API in ember-mocha, this is largely a copy/paste of that effort...
- Loading branch information
Showing
3 changed files
with
70 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,20 @@ | ||
export default function(Constructor) { | ||
return function setupTest(hooks, options) { | ||
let module; | ||
|
||
hooks.before(function() { | ||
// TODO: should we actually have this in the API | ||
module = new Constructor('', options); | ||
}); | ||
|
||
hooks.beforeEach(function() { | ||
module.setContext(this); | ||
|
||
return module.setup(...arguments); | ||
}); | ||
|
||
hooks.afterEach(function() { | ||
return module.teardown(...arguments); | ||
}); | ||
}; | ||
} |
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,35 @@ | ||
/* global setTimeout */ | ||
|
||
import Ember from 'ember'; | ||
import { module, test, setupIntegrationTest } from 'ember-qunit'; | ||
import { setResolverRegistry } from './test-support/resolver'; | ||
|
||
var PrettyColor = Ember.Component.extend({ | ||
classNames: ['pretty-color'], | ||
attributeBindings: ['style'], | ||
style: function(){ | ||
return 'color: ' + this.get('name') + ';'; | ||
}.property('name') | ||
}); | ||
|
||
function setupRegistry() { | ||
setResolverRegistry({ | ||
'component:x-foo': Ember.Component.extend(), | ||
'component:pretty-color': PrettyColor, | ||
'template:components/pretty-color': Ember.Handlebars.compile('Pretty Color: <span class="color-name">{{name}}</span>') | ||
}); | ||
} | ||
|
||
module('component:x-foo', function(hooks) { | ||
hooks.before(setupRegistry); | ||
|
||
setupIntegrationTest(hooks); | ||
|
||
test('renders', function(assert) { | ||
assert.expect(1); | ||
|
||
this.render(Ember.Handlebars.compile(`{{pretty-color name="red"}}`)); | ||
|
||
assert.equal(this.$('.color-name').text(), 'red'); | ||
}); | ||
}); |