|
| 1 | +const components = [ |
| 2 | + { |
| 3 | + name: 'One', |
| 4 | + source: 'one source' |
| 5 | + }, |
| 6 | + { |
| 7 | + name: 'Two', |
| 8 | + source: 'two source' |
| 9 | + } |
| 10 | +]; |
| 11 | + |
| 12 | +const selectedComponent = components[0]; |
| 13 | + |
| 14 | +export default { |
| 15 | + skip: true, // doesn't reflect real-world bug, maybe a JSDOM quirk |
| 16 | + |
| 17 | + data: { |
| 18 | + components, |
| 19 | + selectedComponent |
| 20 | + }, |
| 21 | + |
| 22 | + html: ` |
| 23 | + <select> |
| 24 | + <option value='[object Object]'>One.html</option> |
| 25 | + <option value='[object Object]'>Two.html</option> |
| 26 | + </select> |
| 27 | +
|
| 28 | + <textarea></textarea> |
| 29 | +
|
| 30 | + <pre>ONE SOURCE\nTWO SOURCE</pre> |
| 31 | + `, |
| 32 | + |
| 33 | + test ( assert, component, target, window ) { |
| 34 | + const event = new window.MouseEvent( 'input' ); |
| 35 | + const textarea = target.querySelector( 'textarea' ); |
| 36 | + |
| 37 | + textarea.value = 'one source changed'; |
| 38 | + textarea.dispatchEvent( event ); |
| 39 | + |
| 40 | + assert.equal( component.get( 'compiled' ), 'ONE SOURCE CHANGED\nTWO SOURCE' ); |
| 41 | + assert.htmlEqual( target.innerHTML, ` |
| 42 | + <select> |
| 43 | + <option value='[object Object]'>One.html</option> |
| 44 | + <option value='[object Object]'>Two.html</option> |
| 45 | + </select> |
| 46 | +
|
| 47 | + <textarea></textarea> |
| 48 | +
|
| 49 | + <pre>ONE SOURCE CHANGED\nTWO SOURCE</pre> |
| 50 | + ` ); |
| 51 | + |
| 52 | + // const select = target.querySelector( 'select' ); |
| 53 | + // console.log( `select.options[0].selected`, select.options[0].selected ) |
| 54 | + // console.log( `select.options[1].selected`, select.options[1].selected ) |
| 55 | + // console.log( `select.value`, select.value ) |
| 56 | + // console.log( `select.__value`, select.__value ) |
| 57 | + // select.options[1].selected = true; |
| 58 | + // console.log( `select.options[0].selected`, select.options[0].selected ) |
| 59 | + // console.log( `select.options[1].selected`, select.options[1].selected ) |
| 60 | + // console.log( `select.value`, select.value ) |
| 61 | + // console.log( `select.__value`, select.__value ) |
| 62 | + // select.dispatchEvent( new window.Event( 'change' ) ); |
| 63 | + component.set({ selectedComponent: components[1] }); |
| 64 | + |
| 65 | + assert.equal( textarea.value, 'two source' ); |
| 66 | + |
| 67 | + textarea.value = 'two source changed'; |
| 68 | + textarea.dispatchEvent( event ); |
| 69 | + |
| 70 | + assert.equal( component.get( 'compiled' ), 'ONE SOURCE CHANGED\nTWO SOURCE CHANGED' ); |
| 71 | + assert.htmlEqual( target.innerHTML, ` |
| 72 | + <select> |
| 73 | + <option value='[object Object]'>One.html</option> |
| 74 | + <option value='[object Object]'>Two.html</option> |
| 75 | + </select> |
| 76 | +
|
| 77 | + <textarea></textarea> |
| 78 | +
|
| 79 | + <pre>ONE SOURCE CHANGED\nTWO SOURCE CHANGED</pre> |
| 80 | + ` ); |
| 81 | + |
| 82 | + component.destroy(); |
| 83 | + } |
| 84 | +}; |
0 commit comments