From e601ff8c31023a85d86a8f315c1b18766f589abf Mon Sep 17 00:00:00 2001 From: Esteban Arango Medina Date: Wed, 5 Jul 2017 18:38:59 -0500 Subject: [PATCH] Add missing test for selectFiles on Acceptance. --- tests/acceptance/usage-in-acceptance-test.js | 13 +++++++++- tests/dummy/app/controllers/signup-example.js | 6 +++++ tests/dummy/app/templates/signup-example.hbs | 4 ++++ yarn.lock | 24 ++++--------------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tests/acceptance/usage-in-acceptance-test.js b/tests/acceptance/usage-in-acceptance-test.js index 9394de1..b6bf379 100644 --- a/tests/acceptance/usage-in-acceptance-test.js +++ b/tests/acceptance/usage-in-acceptance-test.js @@ -1,6 +1,6 @@ import { test } from 'qunit'; import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; -import { visit, click, find, fillIn, waitUntil, currentURL, currentRouteName } from 'ember-native-dom-helpers'; +import { visit, click, find, fillIn, waitUntil, currentURL, currentRouteName, selectFiles } from 'ember-native-dom-helpers'; moduleForAcceptance('Acceptance | usage in acceptance', { beforeEach() { @@ -55,3 +55,14 @@ test('Usage using `waitUntil` to test unsettled state', async function(assert) { assert.equal(currentRouteName(), 'dashboard-example', 'The currentRouteName has updated'); assert.ok(find('.dashboard-example-header'), 'We are on the dashboard now'); }); + +test('Usage `selectFiles`', async function(assert) { + await visit('/signup-example'); + + let blob = new Blob(['foo', 'bar'], { type: 'text/plain' }); + let file = new File([blob], 'avatar.png'); + + selectFiles('.signup-example-form__avatar', file); + assert.equal(find('.signup-example-form__avatar-file-name').innerText, 'avatar.png', 'The file name is showed'); +}); + diff --git a/tests/dummy/app/controllers/signup-example.js b/tests/dummy/app/controllers/signup-example.js index c582e32..11a6bc9 100644 --- a/tests/dummy/app/controllers/signup-example.js +++ b/tests/dummy/app/controllers/signup-example.js @@ -2,7 +2,13 @@ import Ember from 'ember'; import fetch from 'fetch'; export default Ember.Controller.extend({ + avatarFileName: null, + actions: { + onFileSelected(event) { + let files = event.target.files; + this.set('avatarFileName', files[0].name); + }, signup() { this.set('isSaving', true); let data = JSON.stringify(this.getProperties('email', 'password', 'passwordConfirmation')); diff --git a/tests/dummy/app/templates/signup-example.hbs b/tests/dummy/app/templates/signup-example.hbs index eb59c60..c912fec 100644 --- a/tests/dummy/app/templates/signup-example.hbs +++ b/tests/dummy/app/templates/signup-example.hbs @@ -1,6 +1,10 @@

Signup example

+

+ Avatar File: + +

Email: diff --git a/yarn.lock b/yarn.lock index 80892c8..81a3253 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1961,21 +1961,7 @@ ember-cli-babel@^5.1.5, ember-cli-babel@^5.1.7: ember-cli-version-checker "^1.0.2" resolve "^1.1.2" -ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7: - version "6.0.0-beta.9" - resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.0.0-beta.9.tgz#b597d52f12d4429cd5716b55f749ebf6144b7b16" - dependencies: - amd-name-resolver "0.0.6" - babel-plugin-transform-es2015-modules-amd "^6.24.0" - babel-polyfill "^6.16.0" - babel-preset-env "^1.2.0" - broccoli-babel-transpiler "^6.0.0" - broccoli-funnel "^1.0.0" - broccoli-source "^1.1.0" - clone "^2.0.0" - ember-cli-version-checker "^1.2.0" - -ember-cli-babel@^6.1.0: +ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.1.0.tgz#d9c83a7d0c67cc8a3ccb9bd082971c3593e54fad" dependencies: @@ -5067,7 +5053,7 @@ read@1, read@~1.0.1, read@~1.0.7: dependencies: mute-stream "~0.0.4" -"readable-stream@1 || 2", readable-stream@^2.0.2, readable-stream@~2.0.5: +"readable-stream@1 || 2", readable-stream@^2, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2, readable-stream@~2.0.5: version "2.0.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" dependencies: @@ -5078,7 +5064,7 @@ read@1, read@~1.0.1, read@~1.0.7: string_decoder "~0.10.x" util-deprecate "~1.0.1" -readable-stream@^2, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.1.4, readable-stream@^2.2.2: +readable-stream@^2.1.4, readable-stream@^2.2.2: version "2.2.9" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" dependencies: @@ -5519,13 +5505,13 @@ signal-exit@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" -silent-error@^1.0.0, silent-error@^1.0.1: +silent-error@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/silent-error/-/silent-error-1.0.1.tgz#71b7d503d1c6f94882b51b56be879b113cb4822c" dependencies: debug "^2.2.0" -silent-error@^1.1.0: +silent-error@^1.0.1, silent-error@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/silent-error/-/silent-error-1.1.0.tgz#2209706f1c850a9f1d10d0d840918b46f26e1bc9" dependencies: