|
| 1 | +/** |
| 2 | + * Copyright 2022 Google LLC. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { initialize } from "../../index"; |
| 18 | +import { Map_ } from "../../maps/maps/map"; |
| 19 | + |
| 20 | +beforeEach(() => { |
| 21 | + initialize(); |
| 22 | +}); |
| 23 | + |
| 24 | +test("Rectangle constructor is mocked", () => { |
| 25 | + expect(new google.maps.Rectangle(null)).toBeTruthy(); |
| 26 | +}); |
| 27 | + |
| 28 | +test("getBounds returns null", () => { |
| 29 | + expect(new google.maps.Rectangle(null).getBounds()).toBeNull(); |
| 30 | +}); |
| 31 | + |
| 32 | +test("getDraggable returns true", () => { |
| 33 | + expect(new google.maps.Rectangle(null).getDraggable()).toBe(true); |
| 34 | +}); |
| 35 | + |
| 36 | +test("getEditable returns true", () => { |
| 37 | + expect(new google.maps.Rectangle(null).getEditable()).toBe(true); |
| 38 | +}); |
| 39 | + |
| 40 | +test("getMap returns map", () => { |
| 41 | + expect(new google.maps.Rectangle(null).getMap()).toBeInstanceOf(Map_); |
| 42 | +}); |
| 43 | + |
| 44 | +test("getVisible returns true", () => { |
| 45 | + expect(new google.maps.Rectangle(null).getVisible()).toBe(true); |
| 46 | +}); |
| 47 | + |
| 48 | +test("setBounds is mocked", () => { |
| 49 | + const rect = new google.maps.Rectangle(null); |
| 50 | + const bounds = { north: 1, east: 2, west: 3, south: 4 }; |
| 51 | + rect.setBounds(bounds); |
| 52 | + expect(rect.setBounds).toHaveBeenCalledWith(bounds); |
| 53 | +}); |
| 54 | + |
| 55 | +test("setDraggable is mocked", () => { |
| 56 | + const rect = new google.maps.Rectangle(null); |
| 57 | + rect.setDraggable(false); |
| 58 | + expect(rect.setDraggable).toHaveBeenCalledWith(false); |
| 59 | +}); |
| 60 | + |
| 61 | +test("setEditable is mocked", () => { |
| 62 | + const rect = new google.maps.Rectangle(null); |
| 63 | + rect.setEditable(false); |
| 64 | + expect(rect.setEditable).toHaveBeenCalledWith(false); |
| 65 | +}); |
| 66 | + |
| 67 | +test("setMap is mocked", () => { |
| 68 | + const rect = new google.maps.Rectangle(null); |
| 69 | + const myMap = {} as any; |
| 70 | + rect.setMap(myMap); |
| 71 | + expect(rect.setMap).toHaveBeenCalledWith({}); |
| 72 | +}); |
| 73 | + |
| 74 | +test("setOptions is mocked", () => { |
| 75 | + const rect = new google.maps.Rectangle(null); |
| 76 | + rect.setOptions({ editable: true }); |
| 77 | + expect(rect.setOptions).toHaveBeenCalledWith({ editable: true }); |
| 78 | +}); |
| 79 | + |
| 80 | +test("setVisible is mocked", () => { |
| 81 | + const rect = new google.maps.Rectangle(null); |
| 82 | + rect.setVisible(false); |
| 83 | + expect(rect.setVisible).toHaveBeenCalledWith(false); |
| 84 | +}); |
0 commit comments