fixed file upload paths in tests
Showing
3 changed files
with
16 additions
and
9 deletions
... | @@ -731,8 +731,11 @@ Casper.prototype.fill = function fill(selector, vals, submit) { | ... | @@ -731,8 +731,11 @@ Casper.prototype.fill = function fill(selector, vals, submit) { |
731 | } else { | 731 | } else { |
732 | (function _each(self) { | 732 | (function _each(self) { |
733 | fillResults.files.forEach(function _forEach(file) { | 733 | fillResults.files.forEach(function _forEach(file) { |
734 | if (!file || !file.path) { | ||
735 | return; | ||
736 | } | ||
734 | if (!fs.exists(file.path)) { | 737 | if (!fs.exists(file.path)) { |
735 | throw new CasperError('Cannot upload unexistent file: ' + file.path); | 738 | throw new CasperError('Cannot upload nonexistent file: ' + file.path); |
736 | } | 739 | } |
737 | var fileFieldSelector = [selector, 'input[name="' + file.name + '"]'].join(' '); | 740 | var fileFieldSelector = [selector, 'input[name="' + file.name + '"]'].join(' '); |
738 | self.page.uploadFile(fileFieldSelector, file.path); | 741 | self.page.uploadFile(fileFieldSelector, file.path); | ... | ... |
1 | /*global casper __utils__*/ | 1 | /*global casper __utils__*/ |
2 | /*jshint strict:false*/ | 2 | /*jshint strict:false*/ |
3 | var fs = require('fs'); | ||
4 | |||
3 | casper.test.begin('fill() tests', 15, function(test) { | 5 | casper.test.begin('fill() tests', 15, function(test) { |
4 | casper.start('tests/site/form.html', function() { | 6 | casper.start('tests/site/form.html', function() { |
5 | this.fill('form[action="result.html"]', { | 7 | this.fill('form[action="result.html"]', { |
... | @@ -101,6 +103,8 @@ casper.test.begin('field array', 1, function(test) { | ... | @@ -101,6 +103,8 @@ casper.test.begin('field array', 1, function(test) { |
101 | }); | 103 | }); |
102 | 104 | ||
103 | casper.test.begin('getFormValues() tests', 2, function(test) { | 105 | casper.test.begin('getFormValues() tests', 2, function(test) { |
106 | var fpath = fs.pathJoin(phantom.casperPath, 'README.md'); | ||
107 | |||
104 | casper.start('tests/site/form.html', function() { | 108 | casper.start('tests/site/form.html', function() { |
105 | this.fill('form[action="result.html"]', { | 109 | this.fill('form[action="result.html"]', { |
106 | email: 'chuck@norris.com', | 110 | email: 'chuck@norris.com', |
... | @@ -109,7 +113,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { | ... | @@ -109,7 +113,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { |
109 | check: true, | 113 | check: true, |
110 | choice: 'no', | 114 | choice: 'no', |
111 | topic: 'bar', | 115 | topic: 'bar', |
112 | file: phantom.casperPath + '/README.md', | 116 | file: fpath, |
113 | 'checklist[]': ['1', '3'] | 117 | 'checklist[]': ['1', '3'] |
114 | }); | 118 | }); |
115 | }); | 119 | }); |
... | @@ -120,7 +124,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { | ... | @@ -120,7 +124,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { |
120 | "choice": "no", | 124 | "choice": "no", |
121 | "content": "Am watching thou", | 125 | "content": "Am watching thou", |
122 | "email": "chuck@norris.com", | 126 | "email": "chuck@norris.com", |
123 | "file": "C:\\fakepath\\README.md", | 127 | "file": fpath, |
124 | "password": "chuck", | 128 | "password": "chuck", |
125 | "submit": "submit", | 129 | "submit": "submit", |
126 | "topic": "bar" | 130 | "topic": "bar" |
... | @@ -134,7 +138,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { | ... | @@ -134,7 +138,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { |
134 | check: true, | 138 | check: true, |
135 | choice: 'yes', | 139 | choice: 'yes', |
136 | topic: 'bar', | 140 | topic: 'bar', |
137 | file: phantom.casperPath + '/README.md', | 141 | file: fpath, |
138 | 'checklist[]': ['1', '3'] | 142 | 'checklist[]': ['1', '3'] |
139 | }); | 143 | }); |
140 | }); | 144 | }); |
... | @@ -145,7 +149,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { | ... | @@ -145,7 +149,7 @@ casper.test.begin('getFormValues() tests', 2, function(test) { |
145 | "choice": "yes", | 149 | "choice": "yes", |
146 | "content": "Am watching thou", | 150 | "content": "Am watching thou", |
147 | "email": "chuck@norris.com", | 151 | "email": "chuck@norris.com", |
148 | "file": "C:\\fakepath\\README.md", | 152 | "file": fpath, |
149 | "password": "chuck", | 153 | "password": "chuck", |
150 | "submit": "submit", | 154 | "submit": "submit", |
151 | "topic": "bar" | 155 | "topic": "bar" | ... | ... |
... | @@ -67,7 +67,7 @@ casper.test.begin('Common assertions tests', 43, function(test) { | ... | @@ -67,7 +67,7 @@ casper.test.begin('Common assertions tests', 43, function(test) { |
67 | }); | 67 | }); |
68 | }); | 68 | }); |
69 | 69 | ||
70 | casper.test.begin('filled inputs', 7, function(test) { | 70 | casper.test.begin('Tester.assertField(): filled inputs', 7, function(test) { |
71 | casper.start('tests/site/form.html', function() { | 71 | casper.start('tests/site/form.html', function() { |
72 | this.fill('form[action="result.html"]', { | 72 | this.fill('form[action="result.html"]', { |
73 | 'email': '', | 73 | 'email': '', |
... | @@ -90,8 +90,8 @@ casper.test.begin('filled inputs', 7, function(test) { | ... | @@ -90,8 +90,8 @@ casper.test.begin('filled inputs', 7, function(test) { |
90 | }); | 90 | }); |
91 | }); | 91 | }); |
92 | 92 | ||
93 | casper.test.begin('unfilled inputs', 7, function(test) { | 93 | casper.test.begin('Tester.assertField(): unfilled inputs', 7, function(test) { |
94 | var fpath = phantom.libraryPath + '/README.md'; | 94 | var fpath = fs.pathJoin(phantom.casperPath, 'README.md'); |
95 | casper.start('tests/site/form.html', function() { | 95 | casper.start('tests/site/form.html', function() { |
96 | this.fill('form[action="result.html"]', { | 96 | this.fill('form[action="result.html"]', { |
97 | 'email': 'chuck@norris.com', | 97 | 'email': 'chuck@norris.com', |
... | @@ -107,7 +107,7 @@ casper.test.begin('unfilled inputs', 7, function(test) { | ... | @@ -107,7 +107,7 @@ casper.test.begin('unfilled inputs', 7, function(test) { |
107 | test.assertField('check', true, 'Tester.assertField() works as expected with checkboxes'); | 107 | test.assertField('check', true, 'Tester.assertField() works as expected with checkboxes'); |
108 | test.assertField('choice', 'no', 'Tester.assertField() works as expected with radios'); | 108 | test.assertField('choice', 'no', 'Tester.assertField() works as expected with radios'); |
109 | test.assertField('topic', 'bar', 'Tester.assertField() works as expected with selects'); | 109 | test.assertField('topic', 'bar', 'Tester.assertField() works as expected with selects'); |
110 | test.assertField('file', 'C:\\fakepath\\README.md', 'Tester.assertField() works as expected with file inputs'); | 110 | test.assertField('file', fpath, 'Tester.assertField() works as expected with file inputs'); |
111 | test.assertField('checklist[]', ['1', '3'], 'Tester.assertField() works as expected with check lists'); | 111 | test.assertField('checklist[]', ['1', '3'], 'Tester.assertField() works as expected with check lists'); |
112 | }).run(function() { | 112 | }).run(function() { |
113 | test.done(); | 113 | test.done(); | ... | ... |
-
Please register or sign in to post a comment