Add test editors

This commit is contained in:
Julia Radzhabova
2021-08-26 00:35:09 +03:00
parent ca4f5cb820
commit 82e05fb859
8 changed files with 40 additions and 1 deletions

View File

@ -1,89 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Unit Tests</title>
<link rel="stylesheet" href="../../build/node_modules/mocha/mocha.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="mocha"></div>
<script src="../../build/node_modules/mocha/mocha.js" type="text/javascript" charset="utf-8"></script>
<script src="../../vendor/requirejs/require.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// Partial config file
require.config({
// Base URL relative to the test runner
// Paths are relative to this
baseUrl: '../../apps/',
paths: {
// Testing libs
'common' : 'common',
'chai' : '../build/node_modules/chai/chai',
'jquery' : '../vendor/jquery/jquery.min',
'underscore' : '../vendor/underscore/underscore',
'backbone' : '../vendor/backbone/backbone',
'bootstrap' : '../vendor/bootstrap/dist/js/bootstrap',
'perfectscrollbar' : '../vendor/perfect-scrollbar/src/perfect-scrollbar',
'jmousewheel' : '../vendor/perfect-scrollbar/src/jquery.mousewheel'
},
shim: {
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
bootstrap: {
deps: [
'jquery'
]
},
common: {
deps: [
'backbone'
]
},
jmousewheel: {
deps: [
'jquery'
]
},
perfectscrollbar: {
deps: [
'jmousewheel'
]
}
}
// urlArgs: /debug\=1/.test(window.location.search) ? '' : 'bust=' + (new Date()).getTime(), // debug
});
// You can do this in the grunt config for each mocha task, see the `options` config
mocha.setup({
ui: 'bdd',
ignoreLeaks: true
});
// Protect from barfs
console = window.console || function() {};
// Don't track
window.notrack = true;
// Mocha run helper, used for browser
var runMocha = function() {
mocha.run();
};
require([
'../test/common',
'../../test/common/main/lib/util/utils.js',
'../../test/common/main/lib/component/Button.js'
], runMocha);
</script>
</body>
</html>

View File

@ -1,115 +0,0 @@
/**
* Button.js
*
* Unit test
*
* Created by Alexander Yuzhin on 6/20/14
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
*
*/
define([
'backbone',
'../../../../../apps/common/main/lib/component/Button.js',
'../../../../../apps/common/main/lib/component/Menu.js'
],function() {
var chai = require('chai'),
should = chai.should();
describe('Common.UI.Button', function(){
var button,
domPlaceholder = document.createElement('div');
it('Create simple button', function(){
$('body').append(domPlaceholder);
button = new Common.UI.Button({
id: 'id-btn-simple',
caption: 'test'
});
button.render($(domPlaceholder));
should.exist(button);
$('#id-btn-simple').should.have.length(1);
});
it('Button caption', function(){
button.caption.should.equal('test');
});
it('Button update caption', function(){
button.setCaption('update caption');
// object
button.caption.should.equal('update caption');
// dom
assert.equal(button.cmpEl.find('button:first').andSelf().filter('button').text(), 'update caption', 'dom caption');
});
it('Button toggle', function(){
button.toggle();
assert.equal(button.isActive(), true, 'should by active');
button.toggle();
assert.equal(button.isActive(), false, 'should NOT by active');
button.toggle(false);
assert.equal(button.isActive(), false, 'should NOT by active');
button.toggle(true);
assert.equal(button.isActive(), true, 'should by active');
button.toggle(false);
});
it('Button disable', function(){
assert.equal(button.isDisabled(), false, 'should NOT by disable');
button.setDisabled(true);
assert.equal(button.isDisabled(), true, 'should by disable');
button.setDisabled(false);
assert.equal(button.isDisabled(), false, 'should NOT by disable');
});
it('Remove simple button', function(){
button.remove();
$('#id-btn-simple').should.have.length(0);
button = null;
// domPlaceholder.remove();
});
it('Create split button', function(){
$('body').append(domPlaceholder);
button = new Common.UI.Button({
id : 'id-btn-split',
caption : 'split',
split : true,
menu : new Common.UI.Menu({
items: [
{
caption: 'print',
value: 'print'
}
]
})
});
button.render($(domPlaceholder));
should.exist(button);
$('#id-btn-split').should.have.length(1);
$('#id-btn-split button').should.have.length(2);
});
it('Remove split button', function(){
button.remove();
$('#id-btn-split').should.have.length(0);
button = null;
// domPlaceholder.remove();
});
});
});

View File

@ -1,33 +0,0 @@
/**
* utils.js
*
* Unit test
*
* Created by Alexander Yuzhin on 5/7/14
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
*
*/
define([
'../../../../../apps/common/main/lib/util/utils.js'
],function() {
describe('Common.Utils.String', function(){
it('Test format', function(){
assert.equal('successively: first, second', Common.Utils.String.format('successively: {0}, {1}', 'first', 'second'));
assert.equal('revers: second, first', Common.Utils.String.format('revers: {1}, {0}', 'first', 'second'));
});
it('Test htmlEncode', function(){
assert.equal('Curly, Larry &amp; Moe', Common.Utils.String.htmlEncode('Curly, Larry & Moe'));
});
it('Test htmlDecode', function(){
assert.equal('Curly, Larry & Moe', Common.Utils.String.htmlDecode('Curly, Larry &amp; Moe'));
});
it('Test ellipsis', function(){
assert.equal('Truncate a s...', Common.Utils.String.ellipsis('Truncate a string and add an ellipsis', 15));
assert.equal('Truncate a string and add...', Common.Utils.String.ellipsis('Truncate a string and add an ellipsis', 30, true));
});
});
});