-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from CenterForOpenScience/feature/tests
[EOSF-594] Add example controller unit tests and component integration tests
- Loading branch information
Showing
9 changed files
with
1,238 additions
and
1,026 deletions.
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
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
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,37 @@ | ||
import Ember from 'ember'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import FactoryGuy, { manualSetup } from 'ember-data-factory-guy'; | ||
|
||
moduleForComponent('author-link', 'Integration | Component | author link', { | ||
integration: true, | ||
beforeEach: function() { | ||
manualSetup(this.container); | ||
} | ||
}); | ||
|
||
test('renders non-links', function(assert) { | ||
let contributorModel = FactoryGuy.make('contributor'); | ||
// Problem here is that author link expects a share search-result contributor, | ||
// not a store instance of a contributor and its user(s). | ||
let contributor = {users: {identifiers: []}}; | ||
contributor.users.name = contributorModel.get('users.fullName'); | ||
contributor = Ember.merge(contributor, contributorModel.serialize().data.attributes); | ||
this.set('contributor', contributor); | ||
this.render(hbs`{{author-link contributor=contributor}}`); | ||
assert.ok(!this.$('a').length, 'Found a link when user has no identifiers'); | ||
assert.equal(this.$().text().trim(), contributorModel.get('users.fullName'), 'Text of author-link not equal to fullName of user'); | ||
}); | ||
|
||
test('renders links', function(assert) { | ||
let contributorModel = FactoryGuy.make('contributor'); | ||
let contributor = {users: {identifiers: []}}; | ||
contributor.users.name = contributorModel.get('users.fullName'); | ||
contributor = Ember.merge(contributor, contributorModel.serialize().data.attributes); | ||
contributor.users.identifiers.push('https://staging.osf.io/cool'); | ||
this.set('contributor', contributor); | ||
|
||
this.render(hbs`{{author-link contributor=contributor}}`); | ||
assert.ok(this.$('a').length, 'Expected a link in author-link as user has an identifier'); | ||
assert.equal(this.$().text().trim(), contributorModel.get('users.fullName'), 'Text of author-link not equal to fullName of user'); | ||
}); |
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
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
Oops, something went wrong.