forked from enviPath/enviPy
Current Dev State
This commit is contained in:
8
static/js/ketcher2/node_modules/font-face-observer/test/assets/index.html
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/font-face-observer/test/assets/index.html
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
hello
|
||||
</body>
|
||||
</html>
|
||||
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/sourcesanspro-regular.eot
generated
vendored
Executable file
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/sourcesanspro-regular.eot
generated
vendored
Executable file
Binary file not shown.
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/sourcesanspro-regular.woff
generated
vendored
Executable file
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/sourcesanspro-regular.woff
generated
vendored
Executable file
Binary file not shown.
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/subset.eot
generated
vendored
Executable file
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/subset.eot
generated
vendored
Executable file
Binary file not shown.
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/subset.woff
generated
vendored
Executable file
BIN
static/js/ketcher2/node_modules/font-face-observer/test/assets/subset.woff
generated
vendored
Executable file
Binary file not shown.
63
static/js/ketcher2/node_modules/font-face-observer/test/dom_spec.js
generated
vendored
Normal file
63
static/js/ketcher2/node_modules/font-face-observer/test/dom_spec.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
describe('dom', function () {
|
||||
var dom = require('../src/dom');
|
||||
var jsdom = require('jsdom').jsdom;
|
||||
|
||||
beforeEach(function() {
|
||||
document = jsdom('<html><head></head><body></body></html>');
|
||||
});
|
||||
|
||||
describe('createElement', function () {
|
||||
it('creates an element', function () {
|
||||
expect(dom.createElement('div'), 'not to be null');
|
||||
expect(dom.createElement('div').nodeName, 'to equal', 'DIV');
|
||||
});
|
||||
});
|
||||
|
||||
describe('createText', function () {
|
||||
it('creates a text node', function () {
|
||||
expect(dom.createText('hello'), 'not to be null');
|
||||
expect(dom.createText('world').textContent, 'to equal', 'world');
|
||||
});
|
||||
});
|
||||
|
||||
describe('style', function () {
|
||||
it('sets the style', function () {
|
||||
var el = dom.createElement('div');
|
||||
|
||||
dom.style(el, 'font-size:12px');
|
||||
|
||||
expect(el.style.fontSize, 'to equal', '12px');
|
||||
});
|
||||
});
|
||||
|
||||
describe('append', function () {
|
||||
it('adds a child node', function () {
|
||||
var parent = dom.createElement('div');
|
||||
|
||||
dom.append(parent, dom.createElement('div'));
|
||||
|
||||
expect(parent.childNodes.length, 'to equal', 1);
|
||||
|
||||
dom.append(parent, dom.createElement('div'));
|
||||
|
||||
expect(parent.childNodes.length, 'to equal', 2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove', function () {
|
||||
it('removes child nodes', function () {
|
||||
var parent = dom.createElement('div'),
|
||||
child1 = dom.createElement('div'),
|
||||
child2 = dom.createElement('div');
|
||||
|
||||
dom.append(parent, child1);
|
||||
dom.append(parent, child2);
|
||||
|
||||
dom.remove(parent, child1);
|
||||
expect(parent.childNodes.length, 'to equal', 1);
|
||||
|
||||
dom.remove(parent, child2);
|
||||
expect(parent.childNodes.length, 'to equal', 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
73
static/js/ketcher2/node_modules/font-face-observer/test/index.html
generated
vendored
Normal file
73
static/js/ketcher2/node_modules/font-face-observer/test/index.html
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>FontFaceObserver</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="../node_modules/mocha/mocha.css" rel="stylesheet">
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: observer-test1;
|
||||
src: url(assets/sourcesanspro-regular.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: observer-test2;
|
||||
src: url(unknown.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: observer-test3;
|
||||
src: url(assets/sourcesanspro-regular.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: observer-test4;
|
||||
src: url(assets/subset.woff) format('woff');
|
||||
unicode-range: u+0021;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: observer-test5;
|
||||
src: url(assets/subset.woff) format('woff');
|
||||
unicode-range: u+4e2d,u+56fd;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: observer-test6;
|
||||
src: url(assets/subset.woff) format('woff');
|
||||
unicode-range: u+10ffff;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: observer-test7;
|
||||
src: url(assets/subset.woff) format('woff');
|
||||
unicode-range: u+23;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script>CLOSURE_NO_DEPS = true;</script>
|
||||
<script src="../vendor/google/base.js"></script>
|
||||
<script src="../vendor/sunesimonsen/unexpected.js"></script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/sinon/pkg/sinon.js"></script>
|
||||
<script src="../node_modules/promis/promise.js"></script>
|
||||
<script src="deps.js"></script>
|
||||
<script>
|
||||
goog.require('fontface.Observer');
|
||||
mocha.ui('bdd');
|
||||
|
||||
expect = weknowhow.expect;
|
||||
</script>
|
||||
<script src="./dom-test.js"></script>
|
||||
<script src="./ruler-test.js"></script>
|
||||
<script src="./observer-test.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
mocha.run();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
255
static/js/ketcher2/node_modules/font-face-observer/test/observer-test.js
generated
vendored
Normal file
255
static/js/ketcher2/node_modules/font-face-observer/test/observer-test.js
generated
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
describe('Observer', function () {
|
||||
var Observer = fontface.Observer,
|
||||
Ruler = fontface.Ruler;
|
||||
|
||||
describe('#constructor', function () {
|
||||
it('creates a new instance with the correct signature', function () {
|
||||
var observer = new Observer('my family', {});
|
||||
expect(observer, 'not to be', null);
|
||||
expect(observer.check, 'to be a function');
|
||||
});
|
||||
|
||||
it('parses descriptors', function () {
|
||||
var observer = new Observer('my family', {
|
||||
weight: 'bold'
|
||||
});
|
||||
|
||||
expect(observer.family, 'to equal', 'my family');
|
||||
expect(observer.weight, 'to equal', 'bold');
|
||||
});
|
||||
|
||||
it('defaults descriptors that are not given', function () {
|
||||
var observer = new Observer('my family', {
|
||||
weight: 'bold'
|
||||
});
|
||||
|
||||
expect(observer.variant, 'to equal', 'normal');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getStyle', function () {
|
||||
it('creates the correct default style', function () {
|
||||
var observer = new Observer('my family', {});
|
||||
|
||||
expect(observer.getStyle(), 'to equal', 'font-style:normal;font-variant:normal;font-weight:normal;font-stretch:stretch;font-feature-settings:normal;-moz-font-feature-settings:normal;-webkit-font-feature-settings:normal;');
|
||||
});
|
||||
|
||||
it('passes through all descriptors', function () {
|
||||
var observer = new Observer('my family', {
|
||||
style: 'italic',
|
||||
variant: 'small-caps',
|
||||
weight: 'bold',
|
||||
stretch: 'condensed',
|
||||
featureSettings: '"kern" 1'
|
||||
});
|
||||
|
||||
expect(observer.getStyle(), 'to equal', 'font-style:italic;font-variant:small-caps;font-weight:bold;font-stretch:condensed;font-feature-settings:"kern" 1;-moz-font-feature-settings:"kern" 1;-webkit-font-feature-settings:"kern" 1;');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#check', function () {
|
||||
this.timeout(5000);
|
||||
|
||||
it('finds a font and resolve the promise', function (done) {
|
||||
var observer = new Observer('observer-test1', {}),
|
||||
ruler = new Ruler('hello');
|
||||
|
||||
document.body.appendChild(ruler.getElement());
|
||||
|
||||
ruler.setFont('monospace', '');
|
||||
var beforeWidth = ruler.getWidth();
|
||||
|
||||
ruler.setFont('observer-test1, monospace', '');
|
||||
observer.check(null, 5000).then(function () {
|
||||
var activeWidth = ruler.getWidth();
|
||||
|
||||
expect(activeWidth, 'not to equal', beforeWidth);
|
||||
|
||||
setTimeout(function () {
|
||||
var afterWidth = ruler.getWidth();
|
||||
|
||||
expect(afterWidth, 'to equal', activeWidth);
|
||||
expect(afterWidth, 'not to equal', beforeWidth);
|
||||
document.body.removeChild(ruler.getElement());
|
||||
done();
|
||||
}, 0);
|
||||
}, function () {
|
||||
done(new Error('Timeout'));
|
||||
});
|
||||
});
|
||||
|
||||
it('fails to find a font and reject the promise', function (done) {
|
||||
var observer = new Observer('observer-test2', {});
|
||||
|
||||
observer.check(null, 50).then(function () {
|
||||
done(new Error('Should not resolve'));
|
||||
}, function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('finds the font even if it is already loaded', function (done) {
|
||||
var observer = new Observer('observer-test3', {});
|
||||
|
||||
observer.check(null, 5000).then(function () {
|
||||
observer.check(null, 5000).then(function () {
|
||||
done();
|
||||
}, function () {
|
||||
done(new Error('Second call failed'));
|
||||
});
|
||||
}, function () {
|
||||
done(new Error('Timeout'));
|
||||
});
|
||||
});
|
||||
|
||||
it('finds a font with a custom unicode range within ASCII', function (done) {
|
||||
var observer = new Observer('observer-test4', {}),
|
||||
ruler = new Ruler('\u0021');
|
||||
|
||||
ruler.setFont('monospace', '');
|
||||
document.body.appendChild(ruler.getElement());
|
||||
|
||||
var beforeWidth = ruler.getWidth();
|
||||
|
||||
ruler.setFont('observer-test4,monospace', '');
|
||||
|
||||
observer.check('\u0021', 5000).then(function () {
|
||||
var activeWidth = ruler.getWidth();
|
||||
|
||||
expect(activeWidth, 'not to equal', beforeWidth);
|
||||
|
||||
setTimeout(function () {
|
||||
var afterWidth = ruler.getWidth();
|
||||
|
||||
expect(afterWidth, 'to equal', activeWidth);
|
||||
expect(afterWidth, 'not to equal', beforeWidth);
|
||||
|
||||
document.body.removeChild(ruler.getElement());
|
||||
done();
|
||||
}, 0);
|
||||
}, function () {
|
||||
done(new Error('Timeout'));
|
||||
});
|
||||
});
|
||||
|
||||
it('finds a font with a custom unicode range outside ASCII (but within BMP)', function (done) {
|
||||
var observer = new Observer('observer-test5', {}),
|
||||
ruler = new Ruler('\u4e2d\u56fd');
|
||||
|
||||
ruler.setFont('monospace', '');
|
||||
document.body.appendChild(ruler.getElement());
|
||||
|
||||
var beforeWidth = ruler.getWidth();
|
||||
|
||||
ruler.setFont('observer-test5,monospace', '');
|
||||
|
||||
observer.check('\u4e2d\u56fd', 5000).then(function () {
|
||||
var activeWidth = ruler.getWidth();
|
||||
|
||||
expect(activeWidth, 'not to equal', beforeWidth);
|
||||
|
||||
setTimeout(function () {
|
||||
var afterWidth = ruler.getWidth();
|
||||
|
||||
expect(afterWidth, 'to equal', activeWidth);
|
||||
expect(afterWidth, 'not to equal', beforeWidth);
|
||||
|
||||
document.body.removeChild(ruler.getElement());
|
||||
|
||||
done();
|
||||
}, 0);
|
||||
}, function () {
|
||||
done(new Error('Timeout'));
|
||||
});
|
||||
});
|
||||
|
||||
it('finds a font with a custom unicode range outside the BMP', function (done) {
|
||||
var observer = new Observer('observer-test6', {}),
|
||||
ruler = new Ruler('\udbff\udfff');
|
||||
|
||||
ruler.setFont('monospace', '');
|
||||
document.body.appendChild(ruler.getElement());
|
||||
|
||||
var beforeWidth = ruler.getWidth();
|
||||
|
||||
ruler.setFont('observer-test6,monospace', '');
|
||||
|
||||
observer.check('\udbff\udfff', 5000).then(function () {
|
||||
var activeWidth = ruler.getWidth();
|
||||
|
||||
expect(activeWidth, 'not to equal', beforeWidth);
|
||||
|
||||
setTimeout(function () {
|
||||
var afterWidth = ruler.getWidth();
|
||||
|
||||
expect(afterWidth, 'to equal', activeWidth);
|
||||
expect(afterWidth, 'not to equal', beforeWidth);
|
||||
|
||||
document.body.removeChild(ruler.getElement());
|
||||
|
||||
done();
|
||||
}, 0);
|
||||
}, function () {
|
||||
done(new Error('Timeout'));
|
||||
});
|
||||
});
|
||||
|
||||
it('fails to find the font if it is available but does not contain the test string', function (done) {
|
||||
var observer = new Observer('observer-test7', {});
|
||||
|
||||
observer.check(null, 50).then(function () {
|
||||
done(new Error('Should not be called'));
|
||||
}, function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasWebKitFallbackBug', function () {
|
||||
var getUserAgent = null;
|
||||
|
||||
beforeEach(function () {
|
||||
Observer.HAS_WEBKIT_FALLBACK_BUG = null;
|
||||
|
||||
getUserAgent = sinon.stub(Observer, 'getUserAgent');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
getUserAgent.restore();
|
||||
});
|
||||
|
||||
it('returns false when the user agent is not WebKit', function () {
|
||||
getUserAgent.returns('Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/15.0 Firefox/14.0');
|
||||
|
||||
expect(Observer.hasWebKitFallbackBug(), 'to be false');
|
||||
});
|
||||
|
||||
it('returns false when the user agent is WebKit but the bug is not present', function () {
|
||||
getUserAgent.returns('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.12 (KHTML, like Gecko) Chrome/20.0.814.2 Safari/536.12');
|
||||
|
||||
expect(Observer.hasWebKitFallbackBug(), 'to be false');
|
||||
});
|
||||
|
||||
it('returns true when the user agent is WebKit and the bug is present', function () {
|
||||
getUserAgent.returns('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.814.2 Safari/536.11');
|
||||
|
||||
expect(Observer.hasWebKitFallbackBug(), 'to be true');
|
||||
});
|
||||
|
||||
it('returns true when the user agent is WebKit and the bug is present in an old version', function () {
|
||||
getUserAgent.returns('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/20.0.814.2 Safari/535.19');
|
||||
|
||||
expect(Observer.hasWebKitFallbackBug(), 'to be true');
|
||||
});
|
||||
|
||||
it('caches the results', function () {
|
||||
getUserAgent.returns('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.814.2 Safari/536.11');
|
||||
|
||||
expect(Observer.hasWebKitFallbackBug(), 'to be true');
|
||||
|
||||
getUserAgent.returns('Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/15.0 Firefox/14.0');
|
||||
|
||||
expect(Observer.hasWebKitFallbackBug(), 'to be true');
|
||||
});
|
||||
});
|
||||
});
|
||||
122
static/js/ketcher2/node_modules/font-face-observer/test/ruler_spec.js
generated
vendored
Normal file
122
static/js/ketcher2/node_modules/font-face-observer/test/ruler_spec.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
describe('Ruler', function () {
|
||||
var Ruler = require('../src/ruler');
|
||||
var ruler = null;
|
||||
var jsdom = require('jsdom').jsdom;
|
||||
|
||||
beforeEach(function (done) {
|
||||
jsdom.env(
|
||||
'<html><head></head><body></body></html>',
|
||||
[],
|
||||
function (errors, window) {
|
||||
ruler = new Ruler('hello');
|
||||
ruler.setFont('', '');
|
||||
ruler.setWidth(100);
|
||||
document.body.appendChild(ruler.getElement());
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
document.body.removeChild(ruler.getElement());
|
||||
ruler = null;
|
||||
});
|
||||
|
||||
describe('#constructor', function () {
|
||||
it('creates a new instance with the correct signature', function () {
|
||||
|
||||
expect(ruler, 'not to be', null);
|
||||
expect(ruler.onResize, 'to be a function');
|
||||
expect(ruler.setFont, 'to be a function');
|
||||
});
|
||||
});
|
||||
|
||||
// describe('#onResize', function () {
|
||||
// it('detects expansion', function (done) {
|
||||
// ruler.onResize(function (width) {
|
||||
// expect(width, 'to equal', 200);
|
||||
// done();
|
||||
// });
|
||||
//
|
||||
// ruler.setWidth(200);
|
||||
// });
|
||||
//
|
||||
// it('detects multiple expansions', function (done) {
|
||||
// var first = true;
|
||||
//
|
||||
// ruler.onResize(function (width) {
|
||||
// if (first) {
|
||||
// expect(width, 'to equal', 200);
|
||||
// ruler.setWidth(300);
|
||||
// first = false;
|
||||
// } else {
|
||||
// expect(width, 'to equal', 300);
|
||||
// done();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ruler.setWidth(200);
|
||||
// });
|
||||
//
|
||||
// it('detects collapse', function (done) {
|
||||
// ruler.onResize(function (width) {
|
||||
// expect(width, 'to equal', 50);
|
||||
// done();
|
||||
// });
|
||||
//
|
||||
// ruler.setWidth(50);
|
||||
// });
|
||||
//
|
||||
// it('detects multiple collapses', function (done) {
|
||||
// var first = true;
|
||||
//
|
||||
// ruler.onResize(function (width) {
|
||||
// if (first) {
|
||||
// expect(width, 'to equal', 70);
|
||||
// ruler.setWidth(50);
|
||||
// first = false;
|
||||
// } else {
|
||||
// expect(width, 'to equal', 50);
|
||||
// done();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ruler.setWidth(70);
|
||||
// });
|
||||
//
|
||||
// it('detects a collapse and an expansion', function (done) {
|
||||
// var first = true;
|
||||
//
|
||||
// ruler.onResize(function (width) {
|
||||
// if (first) {
|
||||
// expect(width, 'to equal', 70);
|
||||
// ruler.setWidth(100);
|
||||
// first = false;
|
||||
// } else {
|
||||
// expect(width, 'to equal', 100);
|
||||
// done();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ruler.setWidth(70);
|
||||
// });
|
||||
//
|
||||
// it('detects an expansion and a collapse', function (done) {
|
||||
// var first = true;
|
||||
//
|
||||
// ruler.onResize(function (width) {
|
||||
// if (first) {
|
||||
// expect(width, 'to equal', 200);
|
||||
// ruler.setWidth(100);
|
||||
// first = false;
|
||||
// } else {
|
||||
// expect(width, 'to equal', 100);
|
||||
// done();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ruler.setWidth(200);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
Reference in New Issue
Block a user