Skip to content

Commit

Permalink
JSLint changes and JS unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
victorette committed Jun 9, 2014
1 parent c3d95b6 commit 2eb665f
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 77 deletions.
1 change: 0 additions & 1 deletion static/js/globals/Tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ function createJSFilesLibrary() {
scriptLibrary.push("static/js2db/lib/jquery.layout.js");

scriptLibrary.push("static/js2db/dbModel/View.js");
scriptLibrary.push("static/js2db/dbModel/Toolbar.js");
scriptLibrary.push("static/js2db/dbModel/locator/PortRightLocator.js");
scriptLibrary.push("static/js2db/dbModel/locator/PortLeftLocator.js");
scriptLibrary.push("static/js2db/dbModel/shape/DBTable.js");
Expand Down
38 changes: 19 additions & 19 deletions static/js/rai/controller/RaccordementController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Ext.define('RAI.controller.RaccordementController', {
extend: 'Ext.app.Controller',

stores: ['ElementsDonneeRightGrid', 'ElementsDonneeLeftGrid', 'Raccordements'],
views: ['raccordement.MainWindow','raccordement.GridPanel','raccordement.ListRaccordement'],
views: ['raccordement.MainWindow', 'raccordement.GridPanel', 'raccordement.ListRaccordement'],

refs: [{
ref: 'mainWindow',
Expand All @@ -31,7 +31,7 @@ Ext.define('RAI.controller.RaccordementController', {
});
},

getReadRaccordementOperation: function() {
getReadRaccordementOperation: function() {
var operation = new Ext.data.Operation({
action: 'read',
params: {
Expand All @@ -40,7 +40,7 @@ Ext.define('RAI.controller.RaccordementController', {
});
return operation;
},

syncListRaccordement: function(listRaccordement) {
var controller = this;

Expand All @@ -60,14 +60,14 @@ Ext.define('RAI.controller.RaccordementController', {
grid.getStore().loadData(model.attributes);
},

removeMask: function(gridPanel) {
removeMask: function(gridPanel) {
gridPanel.getComponent('gridLeft').setLoading(false);
gridPanel.getComponent('gridRight').setLoading(false);
},

openModeleRaccordement: function(win) {
var controller = this;
var model = win.getActiveModel();
var model, controller = this;
model = win.getActiveModel();

params = {
modelID: model
Expand All @@ -89,8 +89,8 @@ Ext.define('RAI.controller.RaccordementController', {
}
};
failureFunction = function(response) {
controller.removeMask(controller.getMainWindow().down('panel'));
console.log('Error on openModeleRaccordement method');
controller.removeMask(controller.getMainWindow().down('panel'));
Ext.Msg.alert('Error', 'Error on openModeleRaccordement method');
};
this.createAjaxRequest('rai/getModeleRaccordement/', "GET", params, null, successFunction, failureFunction);
},
Expand All @@ -107,17 +107,17 @@ Ext.define('RAI.controller.RaccordementController', {
},

raccorderElements: function(button, e, eOpts) {
var controller = this;
var listRaccordement = controller.getMainWindow().getComponent('listRaccordementGrid');
var gridPanel = controller.getMainWindow().down('panel');
var listRaccordement, gridPanel, leftSelection, rightSelection, raccordementsJSON, shouldSyncStore, i, j, controller = this;
listRaccordement = controller.getMainWindow().getComponent('listRaccordementGrid');
gridPanel = controller.getMainWindow().down('panel');

var leftSelection = gridPanel.getComponent('gridLeft').getSelectionModel().getSelection();
var rightSelection = gridPanel.getComponent('gridRight').getSelectionModel().getSelection();
leftSelection = gridPanel.getComponent('gridLeft').getSelectionModel().getSelection();
rightSelection = gridPanel.getComponent('gridRight').getSelectionModel().getSelection();

var raccordementsJSON = [];
var shouldSyncStore = false;
for (var i = 0; i < leftSelection.length; i++) {
for (var j = 0; j < rightSelection.length; j++) {
raccordementsJSON = [];
shouldSyncStore = false;
for (i = 0; i < leftSelection.length; i++) {
for (j = 0; j < rightSelection.length; j++) {
var attribute = controller.createRaccordementAttribute(listRaccordement.getModelRaccordement(), controller.getMainWindow().getActiveModel(), leftSelection[i].data, rightSelection[j].data);
var recordIndex = listRaccordement.getStore().findBy(function(record, id) {
if (record.get('modelName') === listRaccordement.getModelRaccordement() && record.get('sourceName') === attribute.data.sourceName && record.get('targetName') === attribute.data.targetName) {
Expand All @@ -138,7 +138,7 @@ Ext.define('RAI.controller.RaccordementController', {
}

if (shouldSyncStore) {
controller.syncListRaccordement(listRaccordement);
controller.syncListRaccordement(listRaccordement);
}
},

Expand Down
2 changes: 1 addition & 1 deletion static/js/rai/model/ElementDonnee.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*/
Ext.define('RAI.model.ElementDonnee', {
extend: 'Ext.data.Model',
fields: ['id','attributeName', 'entityId', 'entityName']
fields: ['id', 'attributeName', 'entityId', 'entityName']
});
8 changes: 2 additions & 6 deletions static/js/rai/store/ElementsDonneeLeftGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
Ext.define('RAI.store.ElementsDonneeLeftGrid', {
extend: 'Ext.data.Store',

requires: [
'RAI.model.ElementDonnee',
'Ext.data.proxy.Memory',
'Ext.data.reader.Json'
],

requires: ['RAI.model.ElementDonnee', 'Ext.data.proxy.Memory', 'Ext.data.reader.Json'],

sorters: ['attributeName', 'entityName'],
groupField: 'entityName',
constructor: function(cfg) {
Expand Down
8 changes: 2 additions & 6 deletions static/js/rai/store/ElementsDonneeRightGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
Ext.define('RAI.store.ElementsDonneeRightGrid', {
extend: 'Ext.data.Store',

requires: [
'RAI.model.ElementDonnee',
'Ext.data.proxy.Memory',
'Ext.data.reader.Json'
],

requires: ['RAI.model.ElementDonnee', 'Ext.data.proxy.Memory', 'Ext.data.reader.Json'],

sorters: ['attributeName', 'entityName'],
groupField: 'entityName',
constructor: function(cfg) {
Expand Down
2 changes: 1 addition & 1 deletion static/js/rai/store/Raccordements.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Ext.define('RAI.store.Raccordements', {
},
reader: {
type: 'json',
root: 'raccordements',
root: 'raccordements',
successProperty: 'success'
},
pageParam: false,
Expand Down
32 changes: 18 additions & 14 deletions static/js/rai/view/raccordement/GridPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ Ext.define('RAI.view.raccordement.GridPanel', {
itemId: 'gridLeft',
iconCls: 'icon-grid',
frame: true,
features: [Ext.create('Ext.grid.feature.Grouping',{
groupHeaderTpl: 'Entity: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
})],
selModel: Ext.create('Ext.selection.CheckboxModel', {injectCheckbox: 'last'}),
features: [Ext.create('Ext.grid.feature.Grouping', {
groupHeaderTpl: 'Entity: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
})],
selModel: Ext.create('Ext.selection.CheckboxModel', {
injectCheckbox: 'last'
}),
columns: [{
text: 'Attribute',
flex: 1,
Expand All @@ -38,20 +40,22 @@ Ext.define('RAI.view.raccordement.GridPanel', {
dataIndex: 'entityName'
}],
listeners: {
afterrender: function() {
this.setLoading(true);
}
afterrender: function() {
this.setLoading(true);
}
}
}, {
xtype: 'gridpanel',
store: 'ElementsDonneeRightGrid',
itemId: 'gridRight',
iconCls: 'icon-grid',
frame: true,
features: [Ext.create('Ext.grid.feature.Grouping',{
groupHeaderTpl: 'Entity: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
})],
selModel: Ext.create('Ext.selection.CheckboxModel', {injectCheckbox: 'last'}),
features: [Ext.create('Ext.grid.feature.Grouping', {
groupHeaderTpl: 'Entity: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
})],
selModel: Ext.create('Ext.selection.CheckboxModel', {
injectCheckbox: 'last'
}),
columns: [{
text: 'Attribute',
flex: 1,
Expand All @@ -62,9 +66,9 @@ Ext.define('RAI.view.raccordement.GridPanel', {
dataIndex: 'entityName'
}],
listeners: {
afterrender: function() {
this.setLoading(true);
}
afterrender: function() {
this.setLoading(true);
}
}
}],
fbar: [{
Expand Down
4 changes: 2 additions & 2 deletions static/js/rai/view/raccordement/ListRaccordement.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Ext.define('RAI.view.raccordement.ListRaccordement', {
store: 'Raccordements',
title: 'Raccordement',
modelRaccordement: null,

columns: [{
text: 'Element raccordant',
flex: 1,
Expand All @@ -28,7 +28,7 @@ Ext.define('RAI.view.raccordement.ListRaccordement', {
initComponent: function() {
this.dockedItems = [{
xtype: 'toolbar',
items: ['->',{
items: ['->', {
iconCls: 'x-tool-rowDel',
text: _SM.__language.Text_Delete_Button,
action: 'delete'
Expand Down
29 changes: 14 additions & 15 deletions static/js/rai/view/raccordement/MainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Ext.define('RAI.view.raccordement.MainWindow', {
extend: 'Ext.window.Window',
alias: 'widget.raccordementMainWindow',
itemId: 'raccordementMainWindow',
itemId: 'raccordementMainWindow',

layout: {
type: 'vbox',
align: 'stretch'
Expand All @@ -15,33 +15,32 @@ Ext.define('RAI.view.raccordement.MainWindow', {
modal: true,
height: 600,
width: 800,

initComponent: function() {
var me = this;

Ext.applyIf(me, {
items: [
{
items: [{
xtype: 'raccordementGridPanel',
flex: 1
}, {
xtype: 'listRaccordementGrid',
selModel: Ext.create('Ext.selection.CheckboxModel', {injectCheckbox: 'last'}),
selModel: Ext.create('Ext.selection.CheckboxModel', {
injectCheckbox: 'last'
}),
flex: 1
}]
});

me.addEvents(
'openModeleRaccordement'
);
me.on('beforeshow', function(){
this.fireEvent('openModeleRaccordement', me);
});

me.addEvents('openModeleRaccordement');
me.on('beforeshow', function() {
this.fireEvent('openModeleRaccordement', me);
});

me.callParent(arguments);
},

getActiveModel: function() {
return this.selectedModel[0];
return this.selectedModel[0];
}
});
8 changes: 2 additions & 6 deletions static/testing/app-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Ext.Loader.setConfig({enabled: true});
// Ext.Loader.setPath('Name', 'static/path/to/Name');

Ext.Loader.setPath('ProtoUL', 'static/js');

Ext.require('Ext.app.Application');
Expand All @@ -12,10 +12,7 @@ Ext.onReady(function() {
name: 'ProtoUL',
appfolder: 'static/js',
paths: {
'ProtoUL.view.diagram': 'static/js/view/diagram/',
'ProtoUL': 'static/js/',
'ProtoUL.model': 'static/js/model/',
'ProtoUL.store': 'static/js/store/'
'ProtoUL': 'static/js/'
},

models: [
Expand Down Expand Up @@ -44,7 +41,6 @@ Ext.onReady(function() {
'DiagramMenuController'
],
launch: function() {
//include the tests in the test.html head
jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
jasmine.getEnv().execute();
}
Expand Down
12 changes: 6 additions & 6 deletions static/testing/tests/DiagramEditorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ProtoUL.store.Diagrams', function() {
it('calls out to the proper listDiagrams url', function() {
store.load();
var request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toMatch('protoLib/listDiagrams/');
expect(request.url).toMatch('protoDiagram/listDiagrams/');
});

it('New item should be added to store', function() {
Expand Down Expand Up @@ -55,12 +55,12 @@ describe('ProtoUL.controller.DiagramController', function() {
controller.init();
});

it("test createPort", function () {
spyOn(controller, 'createPort');
it("test createEntityAttribute", function () {
spyOn(controller, 'createEntityAttribute');

var port = controller.createPort("draw2d_InputPort","default");
var port = controller.createEntityAttribute('attribute', 'id', 'pk', 'fk', 'string');

expect(controller.createPort).toHaveBeenCalled();
expect(controller.createPort).toHaveBeenCalledWith("draw2d_InputPort","default");
expect(controller.createEntityAttribute).toHaveBeenCalled();
expect(controller.createEntityAttribute).toHaveBeenCalledWith('attribute', 'id', 'pk', 'fk', 'string');
});
});

0 comments on commit 2eb665f

Please sign in to comment.