Skip to content

Commit

Permalink
tests depend on a loaded image
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Feb 13, 2016
1 parent 0e0e20e commit b81ff68
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
7 changes: 6 additions & 1 deletion _develop/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ module.exports = function(config) {

files: [
'dist/quill.css',
'dist/unit.js'
'dist/unit.js',
{ pattern: 'dist/*.map', included: false, served: true },
{ pattern: 'assets/favicon.png', included: false, served: true }
],
proxies: {
'/assets/': '/karma/base/assets/'
},

frameworks: ['jasmine'],
reporters: ['progress'],
Expand Down
9 changes: 2 additions & 7 deletions _develop/proxy.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
var http = require('http');
var httpProxy = require('http-proxy');

var FAVICON = new Buffer('iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACf0lEQVR42r2XS2gTURSG04K2VReilorEECVKiJk8EYuurIgPEFddKW4El1J3FbRUEOzKKuhKdy4Uql0H0UVxoYIKkoWCrxaKz1qKTayNYv0O3IEhzNzecSYz8HNnJpPz3XPm3HPuxGIRHNlstqdQKBwul8tDpVLpDprg/BV63hJgPB7vAngU0HX0BtCSh76FCs7n89sBjqJZDfS343whFHCxWNyEsZvojwb8jok9YKw77tUDwzF6CtW8wPw2zwQvMN51+f3jf4MzmcwaDIxpPBb4S8Zd6JHHM9UgIa/q4OgqObFDQq+Z4G3fcLJ77TLwBSZ4gueSACaXmeRZv2FfidGHGo9+MO7N5XJbDOBLRKjoN+Eu69Y0Xu80haO3mGzzAz+I/np4Pk3YMwLnesoALv8ZMIYnk8lOTTLNCNyyrK2mcPQerTKeAA8PenhRQ70+4T95Vbv9rvcZF0MNPD/EmNDBmeB3qYDSF7geAb7fb+KdcTMM/CTjBtXVnMAv6BY6ThfcHLjUYvS1i1ejKjJPm+7PomP8rT2UJiPvygVekXbL+X3Ne37BcwfCaDRXmuCT6XR6vWwqDJdaRVZQkAl8cPZxIrKHe9cM4Z9RX5DwF5qMnlcygY+TpN1Bwz/sMPpEst6rEjqTUBpRKAmIscfK6C/G07LuNfCG5AsrY10ocGr6ahsoPZtxzsPjRcYbUglD3VwSxn12b0efXMBfVWdMtGRbLXs4j7o/Ltttrle07CNCdT57xyNldkSWUyqV6ojiI6YN2D17wyi5EIvyIPTnFHyOUG+LFA60X9a50pGo4ZZ8QCjvL0Ud9m675kvzCK2V+qh4F9Ez+Xqhkm2MRXz8AzAAXszjgRshAAAAAElFTkSuQmCC', 'base64');

var proxy = httpProxy.createProxyServer({});

var server = http.createServer(function(req, res) {
if (req.url === '/favicon.png') {
res.setHeader('Content-Type', 'image/png');
res.end(FAVICON);
} else if (/\/\d+\.\d+\.\d+/.test(req.url) || req.url.startsWith('/karma/base/dist')) {
if (/\/\d+\.\d+\.\d+/.test(req.url) || req.url.startsWith('/karma/base/dist')) {
proxy.web(req, res, {
ignorePath: true,
target: 'http://localhost:9080/' + req.url.split('/').pop()
});
} else if (req.url.startsWith('/karma')) {
} else if (req.url.startsWith('/karma') || req.url === '/assets/favicon.png') {
proxy.web(req, res, { ignorePath: false, target: { port: 9876 } });
} else {
proxy.web(req, res, { ignorePath: false, target: { port: 4000 } });
Expand Down
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quill",
"version": "0.20.0",
"version": "1.0.0",
"dependencies": {
"clone": "~1.0.2",
"deep-equal": "~1.0.1",
Expand Down Expand Up @@ -32,7 +32,7 @@
"build": "webpack --config _develop/webpack.config.js",
"start": "foreman start -f _develop/procfile",
"test": "karma start _develop/karma.config.js --single-run --browsers Chrome",
"travis": "karma start _develop/karma.config.js --single-run"
"travis": "karma start _develop/karma.config.js --single-run --reporters dots,saucelabs"
},
"private": true
}
6 changes: 3 additions & 3 deletions test/unit/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ describe('Editor', function() {

it('embed', function() {
let editor = this.initialize(Editor, '<p><strong>0123</strong></p>');
editor.insertEmbed(2, 'image', '/favicon.png');
editor.insertEmbed(2, 'image', '/assets/favicon.png');
expect(editor.getDelta()).toEqual(new Delta()
.insert('01', { bold: true })
.insert({ image: '/favicon.png'}, { bold: true })
.insert({ image: '/assets/favicon.png'}, { bold: true })
.insert('23', { bold: true })
.insert('\n')
);
expect(this.container.innerHTML).toEqualHTML('<p><strong>01<img src="/favicon.png">23</strong></p>');
expect(this.container.innerHTML).toEqualHTML('<p><strong>01<img src="/assets/favicon.png">23</strong></p>');
});

it('on empty line', function() {
Expand Down
20 changes: 10 additions & 10 deletions test/unit/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ describe('Selection', function() {
it('between embed', function() {
let selection = this.initialize(Selection, `
<p>
<img src="/favicon.png">
<img src="/favicon.png">
<img src="/assets/favicon.png">
<img src="/assets/favicon.png">
</p>
<ul>
<li>
<img src="/favicon.png">
<img src="/favicon.png">
<img src="/assets/favicon.png">
<img src="/assets/favicon.png">
</li>
</ul>`
);
Expand Down Expand Up @@ -197,13 +197,13 @@ describe('Selection', function() {
it('between embeds', function() {
let selection = this.initialize(Selection, `
<p>
<img src="/favicon.png">
<img src="/favicon.png">
<img src="/assets/favicon.png">
<img src="/assets/favicon.png">
</p>
<ul>
<li>
<img src="/favicon.png">
<img src="/favicon.png">
<img src="/assets/favicon.png">
<img src="/assets/favicon.png">
</li>
</ul>`
);
Expand Down Expand Up @@ -316,8 +316,8 @@ describe('Selection', function() {
it('image', function() {
let selection = this.initialize(Selection, `
<p>
<img src="/favicon.png" width="32px" height="32px">
<img src="/favicon.png" width="32px" height="32px">
<img src="/assets/favicon.png" width="32px" height="32px">
<img src="/assets/favicon.png" width="32px" height="32px">
</p>`
, this.div);
this.bounds = selection.getBounds(1);
Expand Down

0 comments on commit b81ff68

Please sign in to comment.