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 #14 from dortort/chart-options-observer
observe changes to options, fix merge with defaultOptions issue
- Loading branch information
Showing
3 changed files
with
55 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Ember from 'ember'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
const { run: { later } } = Ember; | ||
|
||
const data = [ | ||
['Year', 'Sales', 'Expenses'], | ||
['2004', 1000, 400], | ||
['2005', 1170, 460], | ||
['2006', 660, 1120], | ||
['2007', 1030, 540], | ||
]; | ||
|
||
moduleForComponent('line-chart', 'Integration | Component | chart options change', { | ||
integration: true, | ||
}); | ||
|
||
test('Changing options and rerender', function(assert) { | ||
assert.expect(2); | ||
|
||
const done = assert.async(); | ||
|
||
const title = 'Some legit title'; | ||
|
||
this.setProperties({ | ||
data, | ||
options: { title }, | ||
}); | ||
|
||
this.render(hbs`{{line-chart data=data options=options chartDidRender='chartDidRender'}}`); | ||
|
||
this.on('chartDidRender', () => { | ||
|
||
later(() => { | ||
assert.ok(this.$('div').html().indexOf(title) > -1, 'The component should have a title'); | ||
|
||
this.set('options', {}); | ||
|
||
later(() => { | ||
assert.ok(this.$('div').html().indexOf(title) === -1, 'The component should no longer have a title'); | ||
|
||
done(); | ||
|
||
}, 100); | ||
|
||
}, 500); | ||
|
||
}); | ||
|
||
}); |