()
| 2151 | |
| 2152 | describe('gd.ObjectJsImplementation', function () { |
| 2153 | const createSampleObjectJsImplementation = () => { |
| 2154 | let myObject = new gd.ObjectJsImplementation(); |
| 2155 | myObject.updateProperty = function (propertyName, newValue) { |
| 2156 | if (propertyName === 'My first property') { |
| 2157 | this.content.property1 = newValue; |
| 2158 | return true; |
| 2159 | } |
| 2160 | if (propertyName === 'My other property') { |
| 2161 | this.content.property2 = newValue === '1'; |
| 2162 | return true; |
| 2163 | } |
| 2164 | |
| 2165 | return false; |
| 2166 | }; |
| 2167 | myObject.getProperties = function () { |
| 2168 | let properties = new gd.MapStringPropertyDescriptor(); |
| 2169 | |
| 2170 | properties |
| 2171 | .getOrCreate('My first property') |
| 2172 | .setValue(this.content.property1); |
| 2173 | properties |
| 2174 | .getOrCreate('My other property') |
| 2175 | .setValue(this.content.property2 ? '1' : '0') |
| 2176 | .setType('Boolean'); |
| 2177 | |
| 2178 | return properties; |
| 2179 | }; |
| 2180 | myObject.content = { |
| 2181 | property1: 'Initial value 1', |
| 2182 | property2: true, |
| 2183 | }; |
| 2184 | |
| 2185 | myObject.updateInitialInstanceProperty = function ( |
| 2186 | instance, |
| 2187 | propertyName, |
| 2188 | newValue |
| 2189 | ) { |
| 2190 | if (propertyName === 'My instance property') { |
| 2191 | instance.setRawStringProperty('instanceprop1', newValue); |
| 2192 | return true; |
| 2193 | } |
| 2194 | if (propertyName === 'My other instance property') { |
| 2195 | instance.setRawDoubleProperty('instanceprop2', parseFloat(newValue)); |
| 2196 | return true; |
| 2197 | } |
| 2198 | |
| 2199 | return false; |
| 2200 | }; |
| 2201 | myObject.getInitialInstanceProperties = function (instance) { |
| 2202 | let properties = new gd.MapStringPropertyDescriptor(); |
| 2203 | |
| 2204 | properties |
| 2205 | .getOrCreate('My instance property') |
| 2206 | .setValue(instance.getRawStringProperty('instanceprop1')); |
| 2207 | properties |
| 2208 | .getOrCreate('My other instance property') |
| 2209 | .setValue(instance.getRawDoubleProperty('instanceprop2').toString()) |
| 2210 | .setType('number'); |
no test coverage detected