OLD | NEW |
1 // Test that constructor for the node with name |nodeName| handles the | 1 // Test that constructor for the node with name |nodeName| handles the |
2 // various possible values for channelCount, channelCountMode, and | 2 // various possible values for channelCount, channelCountMode, and |
3 // channelInterpretation. | 3 // channelInterpretation. |
4 | 4 |
5 // The |should| parameter is the test function from new |Audit|. | 5 // The |should| parameter is the test function from new |Audit|. |
6 function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) { | 6 function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) { |
7 if (expectedNodeOptions === undefined) | 7 if (expectedNodeOptions === undefined) |
8 expectedNodeOptions = {}; | 8 expectedNodeOptions = {}; |
9 let node; | 9 let node; |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 new window[name](1); | 183 new window[name](1); |
184 }, 'new ' + name + '(1)').throw('TypeError'); | 184 }, 'new ' + name + '(1)').throw('TypeError'); |
185 should(() => { | 185 should(() => { |
186 new window[name](context, 42); | 186 new window[name](context, 42); |
187 }, 'new ' + name + '(context, 42)').throw('TypeError'); | 187 }, 'new ' + name + '(context, 42)').throw('TypeError'); |
188 } | 188 } |
189 | 189 |
190 function testDefaultConstructor(should, name, context, options) { | 190 function testDefaultConstructor(should, name, context, options) { |
191 let node; | 191 let node; |
192 | 192 |
| 193 let message = options.prefix + ' = new ' + name + '(context'; |
| 194 if (options.constructorOptions) |
| 195 message += ', ' + JSON.stringify(options.constructorOptions); |
| 196 message += ')' |
| 197 |
193 should(() => { | 198 should(() => { |
194 node = new window[name](context); | 199 node = new window[name](context, options.constructorOptions); |
195 }, options.prefix + ' = new ' + name + '(context)').notThrow(); | 200 }, message).notThrow(); |
| 201 |
196 should(node instanceof window[name], options.prefix + ' instanceof ' + name) | 202 should(node instanceof window[name], options.prefix + ' instanceof ' + name) |
197 .beEqualTo(true); | 203 .beEqualTo(true); |
198 | |
199 should(node.numberOfInputs, options.prefix + '.numberOfInputs') | 204 should(node.numberOfInputs, options.prefix + '.numberOfInputs') |
200 .beEqualTo(options.numberOfInputs); | 205 .beEqualTo(options.numberOfInputs); |
201 should(node.numberOfOutputs, options.prefix + '.numberOfOutputs') | 206 should(node.numberOfOutputs, options.prefix + '.numberOfOutputs') |
202 .beEqualTo(options.numberOfOutputs); | 207 .beEqualTo(options.numberOfOutputs); |
203 should(node.channelCount, options.prefix + '.channelCount') | 208 should(node.channelCount, options.prefix + '.channelCount') |
204 .beEqualTo(options.channelCount); | 209 .beEqualTo(options.channelCount); |
205 should(node.channelCountMode, options.prefix + '.channelCountMode') | 210 should(node.channelCountMode, options.prefix + '.channelCountMode') |
206 .beEqualTo(options.channelCountMode); | 211 .beEqualTo(options.channelCountMode); |
207 should(node.channelInterpretation, options.prefix + '.channelInterpretation') | 212 should(node.channelInterpretation, options.prefix + '.channelInterpretation') |
208 .beEqualTo(options.channelInterpretation); | 213 .beEqualTo(options.channelInterpretation); |
209 | 214 |
210 return node; | 215 return node; |
211 } | 216 } |
212 | 217 |
213 function testDefaultAttributes(should, node, prefix, items) { | 218 function testDefaultAttributes(should, node, prefix, items) { |
214 items.forEach((item) => { | 219 items.forEach((item) => { |
215 let attr = node[item.name]; | 220 let attr = node[item.name]; |
216 if (attr instanceof AudioParam) { | 221 if (attr instanceof AudioParam) { |
217 should(attr.value, prefix + '.' + item.name + '.value') | 222 should(attr.value, prefix + '.' + item.name + '.value') |
218 .beEqualTo(item.value); | 223 .beEqualTo(item.value); |
219 } else { | 224 } else { |
220 should(attr, prefix + '.' + item.name).beEqualTo(item.value); | 225 should(attr, prefix + '.' + item.name).beEqualTo(item.value); |
221 } | 226 } |
222 }); | 227 }); |
223 } | 228 } |
OLD | NEW |