Last active
August 29, 2015 14:08
-
-
Save acnalesso/4641bdf00e3967b0b856 to your computer and use it in GitHub Desktop.
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
import Ember from "ember"; | |
import { test, moduleForComponent } from "ember-qunit"; | |
moduleForComponent("show-products"); | |
test('should not show products for the first time', function() { | |
var component = this.subject(); | |
equal(component.get('showingProducts'), false); | |
}); | |
test('should show products when clicked on link', function() { | |
var component = this.subject(); | |
Ember.run(function() { | |
component.send('toggleElement'); | |
}) | |
equal(component.get('showingProducts'), true) | |
}); | |
test('shows one product', function() { | |
var component = this.subject(); | |
Ember.run(function() { | |
component.set('products', [ 'Remote Control']); | |
component.send('toggleElement'); | |
}); | |
equal(this.$().find('ul li').length, 1) | |
}); | |
test('shows multiple products', function() { | |
var component = this.subject(); | |
Ember.run(function() { | |
component.set('products', [ 'Remote Control', 'AAA Battery']); | |
component.send('toggleElement'); | |
}); | |
equal(this.$().find('ul li').length, 2) | |
}) |
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
import Ember from "ember"; | |
export default Ember.Component.extend({ | |
showingProducts: false, | |
toggleElement: function() { | |
this.toggleProperty('showingProducts'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment