From 58ff7e213c4042b6122ac972167b2517eb47428e Mon Sep 17 00:00:00 2001 From: Efthymis Sarmpanis Date: Wed, 27 Dec 2017 18:32:36 +0200 Subject: [PATCH] Failing tests --- test/parser/index.js | 8 ++++++- .../samples/binding-disabled/input.html | 1 + .../samples/binding-disabled/options.json | 3 +++ .../samples/binding-disabled/output.json | 21 +++++++++++++++++++ .../samples/binding-disabled/_config.js | 20 ++++++++++++++++++ .../samples/binding-disabled/main.html | 2 ++ 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/parser/samples/binding-disabled/input.html create mode 100644 test/parser/samples/binding-disabled/options.json create mode 100644 test/parser/samples/binding-disabled/output.json create mode 100644 test/runtime/samples/binding-disabled/_config.js create mode 100644 test/runtime/samples/binding-disabled/main.html 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, `\n

hello 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}}