Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6674 Add tests for TableDisplay with DataGrid. #6701

Merged
merged 5 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions js/notebook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,32 @@
"build:dev": "webpack --config webpack.dev.js --progress && yarn run build-lab-extension",
"build-lab-extension": "cd ../lab && npm install",
"prepublish": "yarn run build:prod",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "TS_NODE_PROJECT=test mocha",
"stats": "webpack --env production --profile --json > stats.json"
},
"devDependencies": {
"@types/chai": "^4.1.1",
"@types/mocha": "^2.2.46",
"base64-loader": "^1.0.0",
"chai": "^4.1.2",
"css-loader": "^0.28.4",
"file-loader": "^0.10.0",
"fork-ts-checker-webpack-plugin": "^0.2.8",
"html-loader": "^0.4.5",
"ignore-styles": "^5.0.1",
"jsdom": "^11.5.1",
"json-loader": "^0.5.4",
"mocha": "^5.0.0",
"node-sass": "^4.5.2",
"sass-loader": "^6.0.5",
"sinon": "^4.2.0",
"source-map-loader": "^0.2.1",
"style-loader": "^0.18.1",
"ts-loader": "^3.0.3",
"typescript": "^2.5.2",
"ts-node": "^4.1.0",
"tsconfig-paths": "^3.1.1",
"tsconfig-paths-webpack-plugin": "^2.0.0",
"typescript": "^2.6.2",
"uglifyjs-webpack-plugin": "^1.0.0-rc.0",
"url-loader": "^0.5.9",
"webpack": "^3.5.6",
Expand Down
87 changes: 40 additions & 47 deletions js/notebook/src/shared/bkUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,45 @@
* limitations under the License.
*/

define([
'./../plot/commonUtils',
'underscore'
], function(
commonUtils,
_
) {
var bkUtils = {
generateId: function(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var commonUtils = require('./../plot/commonUtils');
var _ = require('underscore');

if (_.isUndefined(length)) {
length = 6;
}
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
},
applyTimezone: function(timestamp, tz) {
return commonUtils.applyTimezone(timestamp, tz);
},
formatTimestamp: function(timestamp, tz, format) {
return commonUtils.formatTimestamp(timestamp, tz, format);
},
rgbaToHex: function (r, g, b, a) {
if(a == undefined){
a = 0xFF;
}
var num = ((a & 0xFF) << 24) |
((r & 0xFF) << 16) |
((g & 0xFF) << 8) |
((b & 0xFF));
if(num < 0) {
num = 0xFFFFFFFF + num + 1;
}
return "#" + num.toString(16);
},
timeout: function(fn, ms) {
return setTimeout(fn, ms);
},
newDeferred: function() {
return jQuery.Deferred();
}
};
module.exports = {
generateId: function(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

return bkUtils;
});
if (_.isUndefined(length)) {
length = 6;
}
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
},
applyTimezone: function(timestamp, tz) {
return commonUtils.applyTimezone(timestamp, tz);
},
formatTimestamp: function(timestamp, tz, format) {
return commonUtils.formatTimestamp(timestamp, tz, format);
},
rgbaToHex: function (r, g, b, a) {
if(a == undefined){
a = 0xFF;
}
var num = ((a & 0xFF) << 24) |
((r & 0xFF) << 16) |
((g & 0xFF) << 8) |
((b & 0xFF));
if(num < 0) {
num = 0xFFFFFFFF + num + 1;
}
return "#" + num.toString(16);
},
timeout: function(fn, ms) {
return setTimeout(fn, ms);
},
newDeferred: function() {
return jQuery.Deferred();
}
};
83 changes: 0 additions & 83 deletions js/notebook/src/tableDisplay/consts.js

This file was deleted.

89 changes: 89 additions & 0 deletions js/notebook/src/tableDisplay/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export const scopeData = {
allStringTypes: [
{type: 0, name: 'string'},
{type: 10, name: 'html'}
],
allTimeTypes: [
{type: 8, name: 'datetime'},
{type: 0, name: 'string'}
],
allIntTypes: [
{type: 0, name: 'string'},
{type: 1, name: 'integer'},
{type: 2, name: 'formatted integer'},
{type: 8, name: 'datetime'}
],
allDoubleTypes: [
{type: 0, name: 'string'},
{type: 3, name: 'double'},
{type: 4, name: 'double with precision'},
{type: 6, name: 'exponential 5'},
{type: 7, name: 'exponential 15'}
],
allBoolTypes: [
{type: 0, name: 'string'},
{type: 9, name: 'boolean'}
],
allTypes: [
{type: 0, name: 'string'},
{type: 1, name: 'integer'},
{type: 2, name: 'formatted integer'},
{type: 3, name: 'double'},
{type: 4, name: 'double with precision'},
{type: 6, name: 'exponential 5'},
{type: 7, name: 'exponential 15'},
{type: 8, name: 'datetime'},
{type: 9, name: 'boolean'},
{type: 10, name: 'html'}
],
rowsToDisplayMenu: [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, 'All']
]
};

export const CELL_TYPE = 'bko-tabledisplay';
export const ROW_HEIGHT = 27;
export const ROW_HEIGHT_ADVANCED_MODE = 22;
export const DEFAULT_PAGE_LENGTH = 25;
export const MIN_ROWS_FOR_PAGING = 25;
export const FC_LEFT_SEPARATOR_CLASS = 'left-fix-col-separator';
export const FC_RIGHT_SEPARATOR_CLASS = 'right-fix-col-separator';
export const FC_COL_FIXED_CLASS = 'fix-col-fixed';
export const TIME_UNIT_FORMATS = {
DATETIME: { title: 'datetime', format: 'YYYYMMDD HH:mm:ss.SSS ZZ' },
DAYS: { title: 'date', format: 'YYYYMMDD' },
HOURS: { title: 'hours', format: 'YYYYMMDD HH:mm ZZ' },
MINUTES: { title: 'minutes', format: 'HH:mm ZZ' },
SECONDS: { title: 'seconds', format: 'HH:mm:ss ZZ' },
MILLISECONDS: { title: 'milliseconds', format: 'HH:mm:ss.SSS ZZ' }
};

export default {
scopeData,
CELL_TYPE,
ROW_HEIGHT,
ROW_HEIGHT_ADVANCED_MODE,
DEFAULT_PAGE_LENGTH,
MIN_ROWS_FOR_PAGING,
FC_LEFT_SEPARATOR_CLASS,
FC_RIGHT_SEPARATOR_CLASS,
FC_COL_FIXED_CLASS,
TIME_UNIT_FORMATS
};
Loading