From 33afb7e49a1b194dca7848416c856d486eaeca61 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 11:30:36 -0400 Subject: [PATCH] add some onstate/onupdate tests --- test/runtime/samples/onupdate/_config.js | 21 +++++++++++++++++++ test/runtime/samples/onupdate/main.html | 12 +++++++++++ .../samples/onstate-arrow-no-this/errors.json | 1 + .../samples/onstate-arrow-no-this/input.html | 5 +++++ .../samples/onstate-arrow-this/errors.json | 12 +++++++++++ .../samples/onstate-arrow-this/input.html | 7 +++++++ .../onupdate-arrow-no-this/errors.json | 1 + .../samples/onupdate-arrow-no-this/input.html | 5 +++++ .../samples/onupdate-arrow-this/errors.json | 12 +++++++++++ .../samples/onupdate-arrow-this/input.html | 7 +++++++ 10 files changed, 83 insertions(+) create mode 100644 test/runtime/samples/onupdate/_config.js create mode 100644 test/runtime/samples/onupdate/main.html create mode 100644 test/validator/samples/onstate-arrow-no-this/errors.json create mode 100644 test/validator/samples/onstate-arrow-no-this/input.html create mode 100644 test/validator/samples/onstate-arrow-this/errors.json create mode 100644 test/validator/samples/onstate-arrow-this/input.html create mode 100644 test/validator/samples/onupdate-arrow-no-this/errors.json create mode 100644 test/validator/samples/onupdate-arrow-no-this/input.html create mode 100644 test/validator/samples/onupdate-arrow-this/errors.json create mode 100644 test/validator/samples/onupdate-arrow-this/input.html diff --git a/test/runtime/samples/onupdate/_config.js b/test/runtime/samples/onupdate/_config.js new file mode 100644 index 0000000000..1603c5a74a --- /dev/null +++ b/test/runtime/samples/onupdate/_config.js @@ -0,0 +1,21 @@ +export default { + solo: true, + 'skip-ssr': true, + + data: { + value: 'hello!' + }, + + html: ` +

hello!

+

hello!

+ `, + + test(assert, component, target) { + component.set({ value: 'goodbye!' }); + assert.htmlEqual(target.innerHTML, ` +

goodbye!

+

goodbye!

+ `); + } +}; diff --git a/test/runtime/samples/onupdate/main.html b/test/runtime/samples/onupdate/main.html new file mode 100644 index 0000000000..ea65e9f3d2 --- /dev/null +++ b/test/runtime/samples/onupdate/main.html @@ -0,0 +1,12 @@ +

{{value}}

+

+ + \ No newline at end of file diff --git a/test/validator/samples/onstate-arrow-no-this/errors.json b/test/validator/samples/onstate-arrow-no-this/errors.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/onstate-arrow-no-this/errors.json @@ -0,0 +1 @@ +[] diff --git a/test/validator/samples/onstate-arrow-no-this/input.html b/test/validator/samples/onstate-arrow-no-this/input.html new file mode 100644 index 0000000000..dcd651f66a --- /dev/null +++ b/test/validator/samples/onstate-arrow-no-this/input.html @@ -0,0 +1,5 @@ + diff --git a/test/validator/samples/onstate-arrow-this/errors.json b/test/validator/samples/onstate-arrow-this/errors.json new file mode 100644 index 0000000000..cfcba87f4e --- /dev/null +++ b/test/validator/samples/onstate-arrow-this/errors.json @@ -0,0 +1,12 @@ +[{ + "message": "'onstate' should be a function expression, not an arrow function expression", + "pos": 29, + "loc": { + "line": 3, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } +}] diff --git a/test/validator/samples/onstate-arrow-this/input.html b/test/validator/samples/onstate-arrow-this/input.html new file mode 100644 index 0000000000..f0921ea81d --- /dev/null +++ b/test/validator/samples/onstate-arrow-this/input.html @@ -0,0 +1,7 @@ + diff --git a/test/validator/samples/onupdate-arrow-no-this/errors.json b/test/validator/samples/onupdate-arrow-no-this/errors.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/onupdate-arrow-no-this/errors.json @@ -0,0 +1 @@ +[] diff --git a/test/validator/samples/onupdate-arrow-no-this/input.html b/test/validator/samples/onupdate-arrow-no-this/input.html new file mode 100644 index 0000000000..72c35b0df9 --- /dev/null +++ b/test/validator/samples/onupdate-arrow-no-this/input.html @@ -0,0 +1,5 @@ + diff --git a/test/validator/samples/onupdate-arrow-this/errors.json b/test/validator/samples/onupdate-arrow-this/errors.json new file mode 100644 index 0000000000..e4c1a3a441 --- /dev/null +++ b/test/validator/samples/onupdate-arrow-this/errors.json @@ -0,0 +1,12 @@ +[{ + "message": "'onupdate' should be a function expression, not an arrow function expression", + "pos": 29, + "loc": { + "line": 3, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } +}] diff --git a/test/validator/samples/onupdate-arrow-this/input.html b/test/validator/samples/onupdate-arrow-this/input.html new file mode 100644 index 0000000000..3f4dcd897d --- /dev/null +++ b/test/validator/samples/onupdate-arrow-this/input.html @@ -0,0 +1,7 @@ +