Skip to content

Commit

Permalink
Add a failing test for ember-google-maps/utils/helper scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Jun 1, 2020
1 parent 3a5ab11 commit d10356f
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions __tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,77 @@ describe('when used with @babel/preset-env', () => {

expect(actual).toEqual(`export default Ember.Application.extend({});`);
});

it('does not have issues with ember-google-maps style helper', () => {
let source = `
import { computed, getProperties } from '@ember/object';
import ObjectProxy from '@ember/object/proxy';
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
let ObjectPromiseProxy = ObjectProxy.extend(PromiseProxyMixin);
let position = computed('lat', 'lng', function() {
const { lat, lng } = getProperties(this, 'lat', 'lng');
return (lat && lng) ? new google.maps.LatLng(lat, lng) : undefined;
});
function position2() {
return computed('lat', 'lng', function() {
const { lat, lng } = getProperties(this, 'lat', 'lng');
return (lat && lng) ? new google.maps.LatLng(lat, lng) : undefined;
});
}
function computedPromise(...args) {
let func = args.pop();
return computed(...args, function() {
return ObjectPromiseProxy.create({
promise: func.apply(this)
});
});
}
export { computedPromise, position };
`
let actual = transformWithPresetEnv(source);

expect(actual).toEqual(`
var ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);
var position = Ember.computed('lat', 'lng', function () {
var _Ember$getProperties = Ember.getProperties(this, 'lat', 'lng'),
lat = _Ember$getProperties.lat,
lng = _Ember$getProperties.lng;
return lat && lng ? new google.maps.LatLng(lat, lng) : undefined;
});
function position2() {
return Ember.computed('lat', 'lng', function () {
var _Ember$getProperties2 = Ember.getProperties(this, 'lat', 'lng'),
lat = _Ember$getProperties2.lat,
lng = _Ember$getProperties2.lng;
return lat && lng ? new google.maps.LatLng(lat, lng) : undefined;
});
}
function computedPromise() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var func = args.pop();
return Ember.computed.apply(Ember, args.concat([function () {
return ObjectPromiseProxy.create({
promise: func.apply(this)
});
}]));
}
export { computedPromise, position };
`);
});
});

describe('when used with typescript', () => {
Expand Down

0 comments on commit d10356f

Please sign in to comment.