-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[See here][ava]. Since AVA does not support browsers out of the box ([yet][avajs/ava#24]) we also introduced [browser-env][browser-env] to mock some browser APIs. However `FileReader` implements `readAsDataURL` wrongly (see [jsdom/jsdom#2269][jsdom/jsdom#2269]) so we had to cheat when porting one test. [ava]: https://github.com/avajs/ava [avajs/ava#24]: avajs/ava#24 [browser-env]: https://github.com/lukechilds/browser-env [jsdom/jsdom#2269]: jsdom/jsdom#2269
- Loading branch information
Showing
6 changed files
with
144 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- "5" | ||
- "4" | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- xvfb | ||
|
||
before_script: | ||
- "export DISPLAY=':99.0'" | ||
- "sh -e /etc/init.d/xvfb start" | ||
- sleep 3 | ||
- node | ||
- lts/* | ||
sudo: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import browserEnv from "browser-env"; | ||
import {readFile} from "./files"; | ||
import test from "ava"; | ||
|
||
browserEnv(["window", "File", "FileReader", "btoa", "navigator"]); | ||
|
||
test( | ||
"readfile", | ||
(t) => | ||
readFile(new File(["foo"], "foo.txt", {"type": "text/plain"})) | ||
.then((file) => { | ||
// JSDOM implements FilerReader#readAsDataURL() differently from | ||
// all the browsers. Until that is fixed, we need this spoof | ||
if (navigator.userAgent.match(/jsdom\/11\.\d+\.\d+$/)) { | ||
file.body = btoa("foo"); | ||
} | ||
|
||
t.deepEqual( | ||
file, | ||
{ | ||
"body": "Zm9v", | ||
"name": "foo.txt", | ||
"type": "text/plain", | ||
}, | ||
"Base64 encodes the content" | ||
); | ||
}) | ||
); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.