Skip to content

Commit

Permalink
add an acceptance test; get it to pass by wrapping load callback w/ E…
Browse files Browse the repository at this point in the history
…mber.run()

also handles case where JSAPI is loaded before assertions are run
  • Loading branch information
tomwayson committed Aug 29, 2017
1 parent cda59d7 commit 098e13e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Changed
- added acceptance test

## 0.1.2

### Changed
Expand Down
20 changes: 11 additions & 9 deletions addon/services/esri-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ export default Ember.Service.extend({
// otherwise create a promise that will resolve when the JSAPI is loaded
this._loadPromise = new Ember.RSVP.Promise((resolve, reject) => {
esriLoader.bootstrap(err => {
if (err) {
reject(err);
} else {
// notify any watchers of isLoaded copmuted property
this.notifyPropertyChange('isLoaded');
// let the caller know that the API has been successfully loaded
// TODO: would there be something more useful to return here?
resolve({ success: true });
}
Ember.run(() => {
if (err) {
reject(err);
} else {
// notify any watchers of isLoaded copmuted property
this.notifyPropertyChange('isLoaded');
// let the caller know that the API has been successfully loaded
// TODO: would there be something more useful to return here?
resolve({ success: true });
}
});
}, options);
});
return this._loadPromise;
Expand Down
13 changes: 13 additions & 0 deletions tests/acceptance/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | index');

test('visiting /', function(assert) {
visit('/');

andThen(function() {
assert.equal(currentURL(), '/');
assert.equal(find('p strong span').text().substr(0, 4), 'Load', 'status should be either Loading... or Loaded');
});
});

0 comments on commit 098e13e

Please sign in to comment.