konva/test/unit/Global-test.js

85 lines
3.4 KiB
JavaScript
Raw Normal View History

suite('Global', function() {
// ======================================================
2015-01-27 15:07:51 +08:00
test('test Konva version number', function() {
assert.equal(Konva.version, 'dev');
});
// ======================================================
test('getAngle()', function() {
// test that default angleDeg is true
2015-01-27 15:07:51 +08:00
assert.equal(Konva.angleDeg, true);
assert.equal(Konva.getAngle(180), Math.PI);
2015-01-27 15:07:51 +08:00
Konva.angleDeg = false;
assert.equal(Konva.getAngle(1), 1);
// set angleDeg back to true for future tests
2015-01-27 15:07:51 +08:00
Konva.angleDeg = true;
});
2014-05-14 21:23:44 +08:00
// ======================================================
test('UA tests', function() {
2014-05-14 21:23:44 +08:00
var ua;
// Chrome 34.0.1847.137 m
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'chrome');
assert.equal(ua.mobile, false);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '34.0.1847.137');
assert.equal(ua.ieMobile, false);
// Internet Explorer 9
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'msie');
assert.equal(ua.mobile, false);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '9.0');
assert.equal(ua.ieMobile, false);
// Internet Explorer 10
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'msie');
assert.equal(ua.mobile, false);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '10.0');
assert.equal(ua.ieMobile, false);
// Internet Explorer 10 Mobile (Windows Phone 8)
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'msie');
assert.equal(ua.mobile, true);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '10.0');
2015-01-27 15:07:51 +08:00
assert.equal(ua.ieMobile, true); // <-- forces Konva mouse events to be Konva touch events instead
2014-05-14 21:23:44 +08:00
// Internet Explorer 11 Mobile (Windows Phone 8.1)
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0; Touch; rv:11; IEMobile/11.0; NOKIA; Lumia 928) like Gecko');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'mozilla');
assert.equal(ua.mobile, true);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '11');
2015-01-27 15:07:51 +08:00
assert.equal(ua.ieMobile, true); // <-- forces Konva mouse events to be Konva touch events instead
2014-05-14 21:23:44 +08:00
// Internet Explorer 11 on 64-bit Windows 8.1 with Update
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'mozilla');
assert.equal(ua.mobile, false);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '11.0');
assert.equal(ua.ieMobile, false);
// Windows 8.1 with Update HTML/JS appx
2015-01-27 15:07:51 +08:00
ua = Konva._parseUA('Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; MSAppHost/2.0; rv:11.0) like Gecko');
2014-05-14 21:23:44 +08:00
assert.equal(ua.browser, 'mozilla');
assert.equal(ua.mobile, false);
2014-05-14 21:23:44 +08:00
assert.equal(ua.version, '11.0');
assert.equal(ua.ieMobile, false);
});
2014-05-14 21:23:44 +08:00
});