1
このエラーが発生すると私は約束していますか?未定義のプロパティ 'then'を読み取ることができません
(モックではないので、多くの - 本当のオートコンプリートのより多くの)未定義
it('EmitAreaChanged_AreaEntered_AreaPlaceValueMakesItToHost', async(() => {
let htmlInput = document.createElement("INPUT");
htmlInput.setAttribute("type", "text");
let autocompleteMock = new GoogleAutocompleteMock(testHost.areaPicker, htmlInput);
let x = autocompleteMock.autocomplete.set("place", autocompleteMock.place);
x.then(() => {
expect(testHost.placeValue).toBe(true);
});
return x;
}));
GoogleAutocompleteMockの 'を' プロパティを読み取ることができません:
export class GoogleAutocompleteMock {
autocomplete: any;
area: google.maps.LatLngBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-47.746617, 165.346753),
new google.maps.LatLng(-33.670946, -179.667808)
);
options: Object = {
bounds: this.area
};
constructor(component: any, htmlInput: any) {
this.autocomplete = new google.maps.places.Autocomplete(
<HTMLInputElement>htmlInput, this.options);
this.autocomplete.addListener('place_changed',() => {
component.getAddress(this.autocomplete)
});
}
place = { "address_components": [{ "long_name": "Auckland", "short_name": "Auckland", "types": ["locality", "political"] }, { "long_name": "Auckland", "short_name": "Auckland", "types": ["administrative_area_level_2", "political"] }, { "long_name": "Auckland", "short_name": "Auckland", "types": ["administrative_area_level_1", "political"] }, { "long_name": "New Zealand", "short_name": "NZ", "types": ["country", "political"] }], "adr_address": "<span class=\"locality\">Auckland</span>, <span class=\"country-name\">New Zealand</span>", "formatted_address": "Auckland, New Zealand", "geometry": { "location": { "lat": -36.8484597, "lng": 174.76333150000005 }, "viewport": { "south": -37.0654751, "west": 174.44380160000003, "north": -36.660571, "east": 175.2871371 } }, "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png", "id": "088418ddc17fef2513462d92dbee1355929b35ed", "name": "Auckland", "photos": [{ "height": 1836, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/111644522305605838507/photos\">Johannes De Smedt</a>"], "width": 3264 }, { "height": 2988, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/104449230804367883642/photos\">Michal Panek</a>"], "width": 5312 }, { "height": 3096, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/115717451821958551526/photos\">Sakchhyam Malla</a>"], "width": 4128 }, { "height": 3672, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/100726048745034015308/photos\">Maria Bitunjac</a>"], "width": 4896 }, { "height": 1836, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/112349734260069492163/photos\">Carol Prichard</a>"], "width": 3264 }, { "height": 3120, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/106356366323887392782/photos\">Kovács György</a>"], "width": 4208 }, { "height": 1504, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/117137027694384717244/photos\">Martin Mobers</a>"], "width": 2006 }, { "height": 492, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/102033645464260143092/photos\">Priyesh Bhavsar</a>"], "width": 1000 }, { "height": 2988, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/103221298159348509467/photos\">Alvie Granito</a>"], "width": 5312 }, { "height": 3265, "html_attributions": ["<a href=\"https://maps.google.com/maps/contrib/100418135834547049744/photos\">Simon Chen</a>"], "width": 4898 }], "place_id": "ChIJ--acWvtHDW0RF5miQ2HvAAU", "reference": "CmRbAAAAEJGwhQ0l3O1QapXvbJ_s-xNVyh7UxBjd89D9Q860dfhb5Xh3xeY95UT1tIdugiTRhhZHT2qk_wzUqfd3wPS-vdX1pBljxcPtMUqhTtslzMyVccViA9ckk50Xv_cFWNXFEhCPkvW84Okrk2SJUpUDLGz8GhSEN1dm_0tJj4nEHYo0-bkRdOykYQ", "scope": "GOOGLE", "types": ["locality", "political"], "url": "https://maps.google.com/?q=Auckland,+New+Zealand&ftid=0x6d0d47fb5a9ce6fb:0x500ef6143a29917", "utc_offset": 780, "vicinity": "Auckland" }
}
'set'メソッドのようなものは、約束を返していないようです。あなたはここに 'GoogleAutocompleteMock'のコードを含めることができますか? – 31piy
@ 31piyあなたのコメントはかなり明らかでした、私はgoogle.maps.places.autocomplete.setが約束を返すとは思わない。ありがとう – BeniaminoBaggins