diff --git a/test/parser/index.js b/test/parser/index.js index 1ce8165009..9cf528ac7a 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -1,5 +1,6 @@ import assert from 'assert'; import fs from 'fs'; +import path from 'path'; import { svelte } from '../helpers.js'; describe('parse', () => { @@ -20,8 +21,13 @@ describe('parse', () => { .readFileSync(`test/parser/samples/${dir}/input.html`, 'utf-8') .replace(/\s+$/, ''); + const optionsPath = `test/parser/samples/${dir}/options.json`; + const options = fs.existsSync(optionsPath) ? + JSON.parse(fs.readFileSync(optionsPath, 'utf-8')) : + {}; + try { - const actual = svelte.parse(input); + const actual = svelte.parse(input, options); fs.writeFileSync( `test/parser/samples/${dir}/_actual.json`, JSON.stringify(actual, null, '\t') diff --git a/test/parser/samples/binding-disabled/input.html b/test/parser/samples/binding-disabled/input.html new file mode 100644 index 0000000000..6a7bf8566c --- /dev/null +++ b/test/parser/samples/binding-disabled/input.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/binding-disabled/options.json b/test/parser/samples/binding-disabled/options.json new file mode 100644 index 0000000000..5ece9fc983 --- /dev/null +++ b/test/parser/samples/binding-disabled/options.json @@ -0,0 +1,3 @@ +{ + "bind": false +} diff --git a/test/parser/samples/binding-disabled/output.json b/test/parser/samples/binding-disabled/output.json new file mode 100644 index 0000000000..0a513140d7 --- /dev/null +++ b/test/parser/samples/binding-disabled/output.json @@ -0,0 +1,21 @@ +{ + "hash": 1937205193, + "html": { + "start": 0, + "end": 25, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 25, + "type": "Element", + "name": "input", + "attributes": [ + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} diff --git a/test/runtime/samples/binding-disabled/_config.js b/test/runtime/samples/binding-disabled/_config.js new file mode 100644 index 0000000000..ce173f80af --- /dev/null +++ b/test/runtime/samples/binding-disabled/_config.js @@ -0,0 +1,20 @@ +export default { + data: { + name: 'world' + }, + compileOptions: { + bind: false + }, + html: `\n
hello world
`, + test ( assert, component, target, window ) { + const input = target.querySelector( 'input' ); + assert.equal( input.value, '' ); + + const event = new window.Event( 'input' ); + + input.value = 'everybody'; + input.dispatchEvent( event ); + + assert.equal( target.innerHTML, `\nhello world
` ); + } +}; diff --git a/test/runtime/samples/binding-disabled/main.html b/test/runtime/samples/binding-disabled/main.html new file mode 100644 index 0000000000..806f31fbdd --- /dev/null +++ b/test/runtime/samples/binding-disabled/main.html @@ -0,0 +1,2 @@ + +hello {{name}}