Best JavaScript code snippet using cypress
gc.spread.sheets.angular.11.0.0.js
Source:gc.spread.sheets.angular.11.0.0.js
1"use strict";2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;6 return c > 3 && r && Object.defineProperty(target, key, r), r;7};8var __metadata = (this && this.__metadata) || function (k, v) {9 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);10};11var __param = (this && this.__param) || function (paramIndex, decorator) {12 return function (target, key) { decorator(target, key, paramIndex); }13};14Object.defineProperty(exports, "__esModule", { value: true });15var core_1 = require("@angular/core");16var common_1 = require("@angular/common");17var ColumnComponent = (function () {18 function ColumnComponent() {19 this.changes = {};20 }21 ColumnComponent.prototype.onAttached = function (sheet, index) {22 this.sheet = sheet;23 this.index = index;24 this.onColumnChanged();25 };26 ColumnComponent.prototype.onColumnChanged = function () {27 if (this.sheet) {28 var sheet = this.sheet;29 sheet.suspendPaint();30 sheet.suspendEvent();31 var changes = this.changes;32 for (var changeName in changes) {33 var newValue = changes[changeName].currentValue;34 if (newValue === null || newValue === void 0) {35 continue;36 }37 switch (changeName) {38 case 'width':39 sheet.setColumnWidth(this.index, newValue);40 break;41 case 'visible':42 sheet.setColumnVisible(this.index, newValue);43 break;44 case 'resizable':45 sheet.setColumnResizable(this.index, newValue);46 break;47 case 'autoFit':48 if (newValue) {49 sheet.autoFitColumn(this.index);50 }51 break;52 case 'style':53 sheet.setStyle(-1, this.index, newValue);54 break;55 case 'headerStyle':56 sheet.setStyle(-1, this.index, newValue, GC.Spread.Sheets.SheetArea.colHeader);57 break;58 case 'cellType':59 sheet.setCellType(-1, this.index, newValue);60 break;61 case 'formatter':62 sheet.setFormatter(-1, this.index, newValue, GC.Spread.Sheets.SheetArea.viewport);63 break;64 }65 }66 sheet.resumeEvent();67 sheet.resumePaint();68 }69 };70 ColumnComponent.prototype.ngOnChanges = function (changes) {71 this.changes = {};72 var changesCache = this.changes;73 for (var changeName in changes) {74 changesCache[changeName] = changes[changeName];75 }76 this.onColumnChanged();77 };78 return ColumnComponent;79}());80__decorate([81 core_1.Input(),82 __metadata("design:type", Number)83], ColumnComponent.prototype, "width", void 0);84__decorate([85 core_1.Input(),86 __metadata("design:type", String)87], ColumnComponent.prototype, "dataField", void 0);88__decorate([89 core_1.Input(),90 __metadata("design:type", String)91], ColumnComponent.prototype, "headerText", void 0);92__decorate([93 core_1.Input(),94 __metadata("design:type", Boolean)95], ColumnComponent.prototype, "visible", void 0);96__decorate([97 core_1.Input(),98 __metadata("design:type", Boolean)99], ColumnComponent.prototype, "resizable", void 0);100__decorate([101 core_1.Input(),102 __metadata("design:type", Boolean)103], ColumnComponent.prototype, "autoFit", void 0);104__decorate([105 core_1.Input(),106 __metadata("design:type", GC.Spread.Sheets.Style)107], ColumnComponent.prototype, "style", void 0);108__decorate([109 core_1.Input(),110 __metadata("design:type", GC.Spread.Sheets.CellTypes.Base)111], ColumnComponent.prototype, "cellType", void 0);112__decorate([113 core_1.Input(),114 __metadata("design:type", GC.Spread.Sheets.Style)115], ColumnComponent.prototype, "headerStyle", void 0);116__decorate([117 core_1.Input(),118 __metadata("design:type", Object)119], ColumnComponent.prototype, "formatter", void 0);120ColumnComponent = __decorate([121 core_1.Component({122 selector: 'gc-column',123 template: "\n <ng-content></ng-content>\n "124 })125], ColumnComponent);126exports.ColumnComponent = ColumnComponent;127var WorksheetComponent = (function () {128 function WorksheetComponent() {129 this.sheet = new GC.Spread.Sheets.Worksheet("");130 }131 WorksheetComponent.prototype.onAttached = function () {132 var _this = this;133 var sheet = this.sheet;134 sheet.suspendPaint();135 sheet.suspendEvent();136 if (this.dataSource) {137 sheet.setDataSource(this.dataSource);138 this.columns.forEach(function (columnComponent, index) {139 if (columnComponent.dataField) {140 sheet.bindColumn(index, {141 name: columnComponent.dataField,142 displayName: columnComponent.headerText143 });144 }145 });146 }147 if (this.columns.length > 0) {148 sheet.setColumnCount(this.columns.length);149 this.columns.forEach(function (columnComponent, index) {150 columnComponent.onAttached(_this.sheet, index);151 });152 }153 sheet.resumeEvent();154 sheet.resumePaint();155 };156 WorksheetComponent.prototype.getSheet = function () {157 return this.sheet;158 };159 WorksheetComponent.prototype.ngOnChanges = function (changes) {160 var sheet = this.sheet;161 sheet.suspendPaint();162 sheet.suspendEvent();163 for (var changeName in changes) {164 var newValue = changes[changeName].currentValue;165 if (newValue === null || newValue === void 0) {166 continue;167 }168 switch (changeName) {169 case "rowCount":170 sheet.setRowCount(newValue);171 break;172 case "colCount":173 sheet.setColumnCount(newValue);174 break;175 case "name":176 sheet.name(newValue);177 break;178 case "frozenColumnCount":179 sheet.frozenColumnCount(newValue);180 break;181 case "frozenRowCount":182 sheet.frozenRowCount(newValue);183 break;184 case "frozenTrailingRowCount":185 sheet.frozenTrailingRowCount(newValue);186 break;187 case "frozenTrailingColumnCount":188 sheet.frozenTrailingColumnCount(newValue);189 break;190 case "selectionPolicy":191 sheet.selectionPolicy(newValue);192 break;193 case "selectionUnit":194 sheet.selectionUnit(newValue);195 break;196 case "zoom":197 sheet.zoom(newValue);198 break;199 case "currentTheme":200 sheet.currentTheme(newValue);201 break;202 case "defaultStyle":203 sheet.setDefaultStyle(newValue);204 break;205 case "rowOutlineInfo":206 newValue.forEach(function (item) {207 sheet.rowOutlines.group(item.index, item.count);208 });209 sheet.repaint();210 break;211 case "columnOutlineInfo":212 newValue.forEach(function (item) {213 sheet.columnOutlines.group(item.index, item.count);214 });215 sheet.repaint();216 break;217 case "showRowOutline":218 sheet.showRowOutline(newValue);219 break;220 case "showColumnOutline":221 sheet.showColumnOutline(newValue);222 break;223 case "dataSource":224 sheet.setDataSource(newValue);225 break;226 case "autoGenerateColumns":227 sheet[changeName] = newValue;228 default:229 sheet.options[changeName] = newValue;230 }231 }232 sheet.resumeEvent();233 sheet.resumePaint();234 };235 WorksheetComponent.prototype.ngAfterViewInit = function () {236 var _this = this;237 this.columns.changes.subscribe(function () { _this.onAttached(); });238 };239 return WorksheetComponent;240}());241__decorate([242 core_1.ContentChildren(ColumnComponent),243 __metadata("design:type", core_1.QueryList)244], WorksheetComponent.prototype, "columns", void 0);245__decorate([246 core_1.Input(),247 __metadata("design:type", Number)248], WorksheetComponent.prototype, "rowCount", void 0);249__decorate([250 core_1.Input(),251 __metadata("design:type", Number)252], WorksheetComponent.prototype, "colCount", void 0);253__decorate([254 core_1.Input(),255 __metadata("design:type", Object)256], WorksheetComponent.prototype, "dataSource", void 0);257__decorate([258 core_1.Input(),259 __metadata("design:type", String)260], WorksheetComponent.prototype, "name", void 0);261__decorate([262 core_1.Input(),263 __metadata("design:type", Number)264], WorksheetComponent.prototype, "frozenColumnCount", void 0);265__decorate([266 core_1.Input(),267 __metadata("design:type", Number)268], WorksheetComponent.prototype, "frozenRowCount", void 0);269__decorate([270 core_1.Input(),271 __metadata("design:type", Number)272], WorksheetComponent.prototype, "frozenTrailingRowCount", void 0);273__decorate([274 core_1.Input(),275 __metadata("design:type", Number)276], WorksheetComponent.prototype, "frozenTrailingColumnCount", void 0);277__decorate([278 core_1.Input(),279 __metadata("design:type", Boolean)280], WorksheetComponent.prototype, "allowCellOverflow", void 0);281__decorate([282 core_1.Input(),283 __metadata("design:type", String)284], WorksheetComponent.prototype, "frozenlineColor", void 0);285__decorate([286 core_1.Input(),287 __metadata("design:type", String)288], WorksheetComponent.prototype, "sheetTabColor", void 0);289__decorate([290 core_1.Input(),291 __metadata("design:type", Number)292], WorksheetComponent.prototype, "selectionPolicy", void 0);293__decorate([294 core_1.Input(),295 __metadata("design:type", Number)296], WorksheetComponent.prototype, "selectionUnit", void 0);297__decorate([298 core_1.Input(),299 __metadata("design:type", Number)300], WorksheetComponent.prototype, "zoom", void 0);301__decorate([302 core_1.Input(),303 __metadata("design:type", String)304], WorksheetComponent.prototype, "currentTheme", void 0);305__decorate([306 core_1.Input(),307 __metadata("design:type", Number)308], WorksheetComponent.prototype, "clipBoardOptions", void 0);309__decorate([310 core_1.Input(),311 __metadata("design:type", Boolean)312], WorksheetComponent.prototype, "rowHeaderVisible", void 0);313__decorate([314 core_1.Input(),315 __metadata("design:type", Boolean)316], WorksheetComponent.prototype, "colHeaderVisible", void 0);317__decorate([318 core_1.Input(),319 __metadata("design:type", Number)320], WorksheetComponent.prototype, "rowHeaderAutoText", void 0);321__decorate([322 core_1.Input(),323 __metadata("design:type", Number)324], WorksheetComponent.prototype, "colHeaderAutoText", void 0);325__decorate([326 core_1.Input(),327 __metadata("design:type", Number)328], WorksheetComponent.prototype, "rowHeaderAutoTextIndex", void 0);329__decorate([330 core_1.Input(),331 __metadata("design:type", Number)332], WorksheetComponent.prototype, "colHeaderAutoTextIndex", void 0);333__decorate([334 core_1.Input(),335 __metadata("design:type", Boolean)336], WorksheetComponent.prototype, "isProtected", void 0);337__decorate([338 core_1.Input(),339 __metadata("design:type", Boolean)340], WorksheetComponent.prototype, "showRowOutline", void 0);341__decorate([342 core_1.Input(),343 __metadata("design:type", Boolean)344], WorksheetComponent.prototype, "showColumnOutline", void 0);345__decorate([346 core_1.Input(),347 __metadata("design:type", String)348], WorksheetComponent.prototype, "selectionBackColor", void 0);349__decorate([350 core_1.Input(),351 __metadata("design:type", String)352], WorksheetComponent.prototype, "selectionBorderColor", void 0);353__decorate([354 core_1.Input(),355 __metadata("design:type", GC.Spread.Sheets.Style)356], WorksheetComponent.prototype, "defaultStyle", void 0);357__decorate([358 core_1.Input(),359 __metadata("design:type", Array)360], WorksheetComponent.prototype, "rowOutlineInfo", void 0);361__decorate([362 core_1.Input(),363 __metadata("design:type", Array)364], WorksheetComponent.prototype, "columnOutlineInfo", void 0);365__decorate([366 core_1.Input(),367 __metadata("design:type", Boolean)368], WorksheetComponent.prototype, "autoGenerateColumns", void 0);369WorksheetComponent = __decorate([370 core_1.Component({371 selector: 'gc-worksheet',372 template: "\n <ng-content></ng-content>\n "373 }),374 __metadata("design:paramtypes", [])375], WorksheetComponent);376exports.WorksheetComponent = WorksheetComponent;377var SpreadSheetsComponent = (function () {378 function SpreadSheetsComponent(elRef) {379 this.style = {380 width: '800px',381 height: '600px'382 };383 this.workbookInitialized = new core_1.EventEmitter();384 this.validationError = new core_1.EventEmitter();385 this.cellClick = new core_1.EventEmitter();386 this.cellDoubleClick = new core_1.EventEmitter();387 this.enterCell = new core_1.EventEmitter();388 this.leaveCell = new core_1.EventEmitter();389 this.valueChanged = new core_1.EventEmitter();390 this.topRowChanged = new core_1.EventEmitter();391 this.leftColumnChanged = new core_1.EventEmitter();392 this.invalidOperation = new core_1.EventEmitter();393 this.rangeFiltering = new core_1.EventEmitter();394 this.rangeFiltered = new core_1.EventEmitter();395 this.tableFiltering = new core_1.EventEmitter();396 this.tableFiltered = new core_1.EventEmitter();397 this.rangeSorting = new core_1.EventEmitter();398 this.rangeSorted = new core_1.EventEmitter();399 this.clipboardChanging = new core_1.EventEmitter();400 this.clipboardChanged = new core_1.EventEmitter();401 this.clipboardPasting = new core_1.EventEmitter();402 this.clipboardPasted = new core_1.EventEmitter();403 this.columnWidthChanging = new core_1.EventEmitter();404 this.columnWidthChanged = new core_1.EventEmitter();405 this.rowHeightChanging = new core_1.EventEmitter();406 this.rowHeightChanged = new core_1.EventEmitter();407 this.dragDropBlock = new core_1.EventEmitter();408 this.dragDropBlockCompleted = new core_1.EventEmitter();409 this.dragFillBlock = new core_1.EventEmitter();410 this.dragFillBlockCompleted = new core_1.EventEmitter();411 this.editStarting = new core_1.EventEmitter();412 this.editChange = new core_1.EventEmitter();413 this.editEnding = new core_1.EventEmitter();414 this.editEnd = new core_1.EventEmitter();415 this.editEnded = new core_1.EventEmitter();416 this.rangeGroupStateChanging = new core_1.EventEmitter();417 this.rangeGroupStateChanged = new core_1.EventEmitter();418 this.selectionChanging = new core_1.EventEmitter();419 this.selectionChanged = new core_1.EventEmitter();420 this.sheetTabClick = new core_1.EventEmitter();421 this.sheetTabDoubleClick = new core_1.EventEmitter();422 this.sheetNameChanging = new core_1.EventEmitter();423 this.sheetNameChanged = new core_1.EventEmitter();424 this.userZooming = new core_1.EventEmitter();425 this.userFormulaEntered = new core_1.EventEmitter();426 this.cellChanged = new core_1.EventEmitter();427 this.columnChanged = new core_1.EventEmitter();428 this.rowChanged = new core_1.EventEmitter();429 this.activeSheetChanging = new core_1.EventEmitter();430 this.activeSheetChanged = new core_1.EventEmitter();431 this.sparklineChanged = new core_1.EventEmitter();432 this.rangeChanged = new core_1.EventEmitter();433 this.buttonClicked = new core_1.EventEmitter();434 this.editorStatusChanged = new core_1.EventEmitter();435 this.floatingObjectChanged = new core_1.EventEmitter();436 this.floatingObjectSelectionChanged = new core_1.EventEmitter();437 this.pictureChanged = new core_1.EventEmitter();438 this.floatingObjectRemoving = new core_1.EventEmitter();439 this.floatingObjectRemoved = new core_1.EventEmitter();440 this.pictureSelectionChanged = new core_1.EventEmitter();441 this.floatingObjectLoaded = new core_1.EventEmitter();442 this.touchToolStripOpening = new core_1.EventEmitter();443 this.commentChanged = new core_1.EventEmitter();444 this.commentRemoving = new core_1.EventEmitter();445 this.commentRemoved = new core_1.EventEmitter();446 this.slicerChanged = new core_1.EventEmitter();447 this.elRef = elRef;448 }449 SpreadSheetsComponent.prototype.ngAfterViewInit = function () {450 var _this = this;451 var elRef = this.elRef;452 var dom = elRef.nativeElement;453 var hostElement = dom.querySelector('div');454 this.spread = new GC.Spread.Sheets.Workbook(hostElement, { sheetCount: 0 });455 this.setSpreadOptions();456 this.initSheets();457 this.sheets.changes.subscribe(function () { _this.initSheets(); });458 this.bindCustomEvent(this.spread);459 this.workbookInitialized.emit({ spread: this.spread });460 };461 SpreadSheetsComponent.prototype.initSheets = function () {462 var sheets = this.sheets;463 var spread = this.spread;464 spread.clearSheets();465 sheets.forEach(function (sheetComponent, index) {466 spread.addSheet(index, sheetComponent.getSheet());467 sheetComponent.onAttached();468 });469 if (sheets.length === 0) {470 this.spread.addSheet(0, new GC.Spread.Sheets.Worksheet(""));471 }472 };473 SpreadSheetsComponent.prototype.bindCustomEvent = function (spread) {474 var _this = this;475 var customEventNameSpace = '.ng';476 var events = ['ValidationError', 'CellClick', 'CellDoubleClick', 'EnterCell',477 'LeaveCell', 'ValueChanged', 'TopRowChanged', 'LeftColumnChanged',478 'InvalidOperation', 'RangeFiltering', 'RangeFiltered', 'TableFiltering',479 'TableFiltered', 'RangeSorting', 'RangeSorted', 'ClipboardChanging',480 'ClipboardChanged', 'ClipboardPasting', 'ClipboardPasted', 'ColumnWidthChanging',481 'ColumnWidthChanged', 'RowHeightChanging', 'RowHeightChanged', 'DragDropBlock',482 'DragDropBlockCompleted', 'DragFillBlock', 'DragFillBlockCompleted', 'EditStarting',483 'EditChange', 'EditEnding', 'EditEnd', 'EditEnded', 'RangeGroupStateChanging',484 'RangeGroupStateChanged', 'SelectionChanging', 'SelectionChanged', 'SheetTabClick',485 'SheetTabDoubleClick', 'SheetNameChanging', 'SheetNameChanged',486 'UserZooming', 'UserFormulaEntered', 'CellChanged', 'ColumnChanged',487 'RowChanged', 'ActiveSheetChanging', 'ActiveSheetChanged',488 'SparklineChanged',489 'RangeChanged', 'ButtonClicked', 'EditorStatusChanged',490 'FloatingObjectChanged', 'FloatingObjectSelectionChanged', 'PictureChanged', 'FloatingObjectRemoving', 'FloatingObjectRemoved', 'PictureSelectionChanged',491 'FloatingObjectLoaded', 'TouchToolStripOpening', 'CommentChanged', 'CommentRemoving', 'CommentRemoved', 'SlicerChanged'];492 events.forEach(function (event) {493 spread.bind(event + customEventNameSpace, function (event, data) {494 var eventType = event.type;495 var camelCaseEvent = eventType[0].toLowerCase() + eventType.substr(1);496 _this[camelCaseEvent].emit(data);497 });498 });499 };500 SpreadSheetsComponent.prototype.setSpreadOptions = function () {501 var spread = this.spread;502 if (!this.spread) {503 return;504 }505 spread.suspendEvent();506 spread.suspendPaint();507 var options = this.spreadOptions;508 options && options.forEach(function (option) {509 if (option.name === 'name') {510 spread.name = option.value;511 }512 else {513 spread.options[option.name] = option.value;514 }515 });516 spread.resumePaint();517 spread.resumeEvent();518 };519 SpreadSheetsComponent.prototype.ngOnChanges = function (changes) {520 var options = [];521 for (var changeName in changes) {522 var newValue = changes[changeName].currentValue;523 if (newValue !== null && newValue !== void 0) {524 switch (changeName) {525 case 'hostStyle':526 this.style = newValue;527 break;528 case 'hostClass':529 break;530 default:531 options.push({ name: changeName, value: newValue });532 }533 }534 }535 this.spreadOptions = options;536 this.setSpreadOptions();537 };538 SpreadSheetsComponent.prototype.ngOnDestroy = function () {539 this.spread.destroy();540 };541 return SpreadSheetsComponent;542}());543__decorate([544 core_1.Input(),545 __metadata("design:type", Boolean)546], SpreadSheetsComponent.prototype, "allowUserResize", void 0);547__decorate([548 core_1.Input(),549 __metadata("design:type", Boolean)550], SpreadSheetsComponent.prototype, "allowUserZoom", void 0);551__decorate([552 core_1.Input(),553 __metadata("design:type", Boolean)554], SpreadSheetsComponent.prototype, "allowUserEditFormula", void 0);555__decorate([556 core_1.Input(),557 __metadata("design:type", Boolean)558], SpreadSheetsComponent.prototype, "allowUserDragFill", void 0);559__decorate([560 core_1.Input(),561 __metadata("design:type", Boolean)562], SpreadSheetsComponent.prototype, "allowUserDragDrop", void 0);563__decorate([564 core_1.Input(),565 __metadata("design:type", Boolean)566], SpreadSheetsComponent.prototype, "highlightInvalidData", void 0);567__decorate([568 core_1.Input(),569 __metadata("design:type", Boolean)570], SpreadSheetsComponent.prototype, "newTabVisible", void 0);571__decorate([572 core_1.Input(),573 __metadata("design:type", Boolean)574], SpreadSheetsComponent.prototype, "tabStripVisible", void 0);575__decorate([576 core_1.Input(),577 __metadata("design:type", Boolean)578], SpreadSheetsComponent.prototype, "tabEditable", void 0);579__decorate([580 core_1.Input(),581 __metadata("design:type", Number)582], SpreadSheetsComponent.prototype, "autoFitType", void 0);583__decorate([584 core_1.Input(),585 __metadata("design:type", Number)586], SpreadSheetsComponent.prototype, "referenceStyle", void 0);587__decorate([588 core_1.Input(),589 __metadata("design:type", String)590], SpreadSheetsComponent.prototype, "backColor", void 0);591__decorate([592 core_1.Input(),593 __metadata("design:type", String)594], SpreadSheetsComponent.prototype, "grayAreaBackColor", void 0);595__decorate([596 core_1.Input(),597 __metadata("design:type", Boolean)598], SpreadSheetsComponent.prototype, "showVerticalScrollbar", void 0);599__decorate([600 core_1.Input(),601 __metadata("design:type", Boolean)602], SpreadSheetsComponent.prototype, "showHorizontalScrollbar", void 0);603__decorate([604 core_1.Input(),605 __metadata("design:type", Object)606], SpreadSheetsComponent.prototype, "hostStyle", void 0);607__decorate([608 core_1.Input(),609 __metadata("design:type", String)610], SpreadSheetsComponent.prototype, "hostClass", void 0);611__decorate([612 core_1.Input(),613 __metadata("design:type", String)614], SpreadSheetsComponent.prototype, "name", void 0);615__decorate([616 core_1.Input(),617 __metadata("design:type", String)618], SpreadSheetsComponent.prototype, "backgroundImage", void 0);619__decorate([620 core_1.Input(),621 __metadata("design:type", Number)622], SpreadSheetsComponent.prototype, "backgroundImageLayout", void 0);623__decorate([624 core_1.Input(),625 __metadata("design:type", Number)626], SpreadSheetsComponent.prototype, "showScrollTip", void 0);627__decorate([628 core_1.Input(),629 __metadata("design:type", Number)630], SpreadSheetsComponent.prototype, "showResizeTip", void 0);631__decorate([632 core_1.Input(),633 __metadata("design:type", Boolean)634], SpreadSheetsComponent.prototype, "showDragDropTip", void 0);635__decorate([636 core_1.Input(),637 __metadata("design:type", Boolean)638], SpreadSheetsComponent.prototype, "showDragFillTip", void 0);639__decorate([640 core_1.Output(),641 __metadata("design:type", Object)642], SpreadSheetsComponent.prototype, "workbookInitialized", void 0);643__decorate([644 core_1.Output(),645 __metadata("design:type", Object)646], SpreadSheetsComponent.prototype, "validationError", void 0);647__decorate([648 core_1.Output(),649 __metadata("design:type", Object)650], SpreadSheetsComponent.prototype, "cellClick", void 0);651__decorate([652 core_1.Output(),653 __metadata("design:type", Object)654], SpreadSheetsComponent.prototype, "cellDoubleClick", void 0);655__decorate([656 core_1.Output(),657 __metadata("design:type", Object)658], SpreadSheetsComponent.prototype, "enterCell", void 0);659__decorate([660 core_1.Output(),661 __metadata("design:type", Object)662], SpreadSheetsComponent.prototype, "leaveCell", void 0);663__decorate([664 core_1.Output(),665 __metadata("design:type", Object)666], SpreadSheetsComponent.prototype, "valueChanged", void 0);667__decorate([668 core_1.Output(),669 __metadata("design:type", Object)670], SpreadSheetsComponent.prototype, "topRowChanged", void 0);671__decorate([672 core_1.Output(),673 __metadata("design:type", Object)674], SpreadSheetsComponent.prototype, "leftColumnChanged", void 0);675__decorate([676 core_1.Output(),677 __metadata("design:type", Object)678], SpreadSheetsComponent.prototype, "invalidOperation", void 0);679__decorate([680 core_1.Output(),681 __metadata("design:type", Object)682], SpreadSheetsComponent.prototype, "rangeFiltering", void 0);683__decorate([684 core_1.Output(),685 __metadata("design:type", Object)686], SpreadSheetsComponent.prototype, "rangeFiltered", void 0);687__decorate([688 core_1.Output(),689 __metadata("design:type", Object)690], SpreadSheetsComponent.prototype, "tableFiltering", void 0);691__decorate([692 core_1.Output(),693 __metadata("design:type", Object)694], SpreadSheetsComponent.prototype, "tableFiltered", void 0);695__decorate([696 core_1.Output(),697 __metadata("design:type", Object)698], SpreadSheetsComponent.prototype, "rangeSorting", void 0);699__decorate([700 core_1.Output(),701 __metadata("design:type", Object)702], SpreadSheetsComponent.prototype, "rangeSorted", void 0);703__decorate([704 core_1.Output(),705 __metadata("design:type", Object)706], SpreadSheetsComponent.prototype, "clipboardChanging", void 0);707__decorate([708 core_1.Output(),709 __metadata("design:type", Object)710], SpreadSheetsComponent.prototype, "clipboardChanged", void 0);711__decorate([712 core_1.Output(),713 __metadata("design:type", Object)714], SpreadSheetsComponent.prototype, "clipboardPasting", void 0);715__decorate([716 core_1.Output(),717 __metadata("design:type", Object)718], SpreadSheetsComponent.prototype, "clipboardPasted", void 0);719__decorate([720 core_1.Output(),721 __metadata("design:type", Object)722], SpreadSheetsComponent.prototype, "columnWidthChanging", void 0);723__decorate([724 core_1.Output(),725 __metadata("design:type", Object)726], SpreadSheetsComponent.prototype, "columnWidthChanged", void 0);727__decorate([728 core_1.Output(),729 __metadata("design:type", Object)730], SpreadSheetsComponent.prototype, "rowHeightChanging", void 0);731__decorate([732 core_1.Output(),733 __metadata("design:type", Object)734], SpreadSheetsComponent.prototype, "rowHeightChanged", void 0);735__decorate([736 core_1.Output(),737 __metadata("design:type", Object)738], SpreadSheetsComponent.prototype, "dragDropBlock", void 0);739__decorate([740 core_1.Output(),741 __metadata("design:type", Object)742], SpreadSheetsComponent.prototype, "dragDropBlockCompleted", void 0);743__decorate([744 core_1.Output(),745 __metadata("design:type", Object)746], SpreadSheetsComponent.prototype, "dragFillBlock", void 0);747__decorate([748 core_1.Output(),749 __metadata("design:type", Object)750], SpreadSheetsComponent.prototype, "dragFillBlockCompleted", void 0);751__decorate([752 core_1.Output(),753 __metadata("design:type", Object)754], SpreadSheetsComponent.prototype, "editStarting", void 0);755__decorate([756 core_1.Output(),757 __metadata("design:type", Object)758], SpreadSheetsComponent.prototype, "editChange", void 0);759__decorate([760 core_1.Output(),761 __metadata("design:type", Object)762], SpreadSheetsComponent.prototype, "editEnding", void 0);763__decorate([764 core_1.Output(),765 __metadata("design:type", Object)766], SpreadSheetsComponent.prototype, "editEnd", void 0);767__decorate([768 core_1.Output(),769 __metadata("design:type", Object)770], SpreadSheetsComponent.prototype, "editEnded", void 0);771__decorate([772 core_1.Output(),773 __metadata("design:type", Object)774], SpreadSheetsComponent.prototype, "rangeGroupStateChanging", void 0);775__decorate([776 core_1.Output(),777 __metadata("design:type", Object)778], SpreadSheetsComponent.prototype, "rangeGroupStateChanged", void 0);779__decorate([780 core_1.Output(),781 __metadata("design:type", Object)782], SpreadSheetsComponent.prototype, "selectionChanging", void 0);783__decorate([784 core_1.Output(),785 __metadata("design:type", Object)786], SpreadSheetsComponent.prototype, "selectionChanged", void 0);787__decorate([788 core_1.Output(),789 __metadata("design:type", Object)790], SpreadSheetsComponent.prototype, "sheetTabClick", void 0);791__decorate([792 core_1.Output(),793 __metadata("design:type", Object)794], SpreadSheetsComponent.prototype, "sheetTabDoubleClick", void 0);795__decorate([796 core_1.Output(),797 __metadata("design:type", Object)798], SpreadSheetsComponent.prototype, "sheetNameChanging", void 0);799__decorate([800 core_1.Output(),801 __metadata("design:type", Object)802], SpreadSheetsComponent.prototype, "sheetNameChanged", void 0);803__decorate([804 core_1.Output(),805 __metadata("design:type", Object)806], SpreadSheetsComponent.prototype, "userZooming", void 0);807__decorate([808 core_1.Output(),809 __metadata("design:type", Object)810], SpreadSheetsComponent.prototype, "userFormulaEntered", void 0);811__decorate([812 core_1.Output(),813 __metadata("design:type", Object)814], SpreadSheetsComponent.prototype, "cellChanged", void 0);815__decorate([816 core_1.Output(),817 __metadata("design:type", Object)818], SpreadSheetsComponent.prototype, "columnChanged", void 0);819__decorate([820 core_1.Output(),821 __metadata("design:type", Object)822], SpreadSheetsComponent.prototype, "rowChanged", void 0);823__decorate([824 core_1.Output(),825 __metadata("design:type", Object)826], SpreadSheetsComponent.prototype, "activeSheetChanging", void 0);827__decorate([828 core_1.Output(),829 __metadata("design:type", Object)830], SpreadSheetsComponent.prototype, "activeSheetChanged", void 0);831__decorate([832 core_1.Output(),833 __metadata("design:type", Object)834], SpreadSheetsComponent.prototype, "sparklineChanged", void 0);835__decorate([836 core_1.Output(),837 __metadata("design:type", Object)838], SpreadSheetsComponent.prototype, "rangeChanged", void 0);839__decorate([840 core_1.Output(),841 __metadata("design:type", Object)842], SpreadSheetsComponent.prototype, "buttonClicked", void 0);843__decorate([844 core_1.Output(),845 __metadata("design:type", Object)846], SpreadSheetsComponent.prototype, "editorStatusChanged", void 0);847__decorate([848 core_1.Output(),849 __metadata("design:type", Object)850], SpreadSheetsComponent.prototype, "floatingObjectChanged", void 0);851__decorate([852 core_1.Output(),853 __metadata("design:type", Object)854], SpreadSheetsComponent.prototype, "floatingObjectSelectionChanged", void 0);855__decorate([856 core_1.Output(),857 __metadata("design:type", Object)858], SpreadSheetsComponent.prototype, "pictureChanged", void 0);859__decorate([860 core_1.Output(),861 __metadata("design:type", Object)862], SpreadSheetsComponent.prototype, "floatingObjectRemoving", void 0);863__decorate([864 core_1.Output(),865 __metadata("design:type", Object)866], SpreadSheetsComponent.prototype, "floatingObjectRemoved", void 0);867__decorate([868 core_1.Output(),869 __metadata("design:type", Object)870], SpreadSheetsComponent.prototype, "pictureSelectionChanged", void 0);871__decorate([872 core_1.Output(),873 __metadata("design:type", Object)874], SpreadSheetsComponent.prototype, "floatingObjectLoaded", void 0);875__decorate([876 core_1.Output(),877 __metadata("design:type", Object)878], SpreadSheetsComponent.prototype, "touchToolStripOpening", void 0);879__decorate([880 core_1.Output(),881 __metadata("design:type", Object)882], SpreadSheetsComponent.prototype, "commentChanged", void 0);883__decorate([884 core_1.Output(),885 __metadata("design:type", Object)886], SpreadSheetsComponent.prototype, "commentRemoving", void 0);887__decorate([888 core_1.Output(),889 __metadata("design:type", Object)890], SpreadSheetsComponent.prototype, "commentRemoved", void 0);891__decorate([892 core_1.Output(),893 __metadata("design:type", Object)894], SpreadSheetsComponent.prototype, "slicerChanged", void 0);895__decorate([896 core_1.ContentChildren(WorksheetComponent),897 __metadata("design:type", core_1.QueryList)898], SpreadSheetsComponent.prototype, "sheets", void 0);899SpreadSheetsComponent = __decorate([900 core_1.Component({901 selector: 'gc-spread-sheets',902 template: "\n <div [ngStyle]=\"style\" [ngClass]=\"hostClass\">\n <ng-content></ng-content>\n </div>\n "903 }),904 __param(0, core_1.Inject(core_1.ElementRef)),905 __metadata("design:paramtypes", [core_1.ElementRef])906], SpreadSheetsComponent);907exports.SpreadSheetsComponent = SpreadSheetsComponent;908var SpreadSheetsModule = (function () {909 function SpreadSheetsModule() {910 }911 return SpreadSheetsModule;912}());913SpreadSheetsModule = __decorate([914 core_1.NgModule({915 imports: [common_1.CommonModule],916 declarations: [SpreadSheetsComponent, WorksheetComponent, ColumnComponent],917 exports: [SpreadSheetsComponent, WorksheetComponent, ColumnComponent]918 })919], SpreadSheetsModule);...
page_spread_property_spec.js
Source:page_spread_property_spec.js
1describe("Epub.PageSpreadProperty", function () {2 describe("inferiBooksPageSpread()", function () {3 beforeEach(function () {4 this.pageSpreadDelegate = new Epub.PageSpreadProperty();5 }); 6 it("centers the first page", function () {7 var spineIndex = 0;8 var numSpineItems = 10;9 var pageSpreadClass = this.pageSpreadDelegate.inferiBooksPageSpread(spineIndex, numSpineItems);10 expect(pageSpreadClass).toBe("center_page");11 });12 it("centers the last page if it is an even-numbered page", function () {13 var spineIndex = 9;14 var numSpineItems = 10;15 var pageSpreadClass = this.pageSpreadDelegate.inferiBooksPageSpread(spineIndex, numSpineItems);16 expect(pageSpreadClass).toBe("center_page");17 });18 it("assigns right_page to an even-numbered page", function () {19 var spineIndex = 2;20 var numSpineItems = 10;21 var pageSpreadClass = this.pageSpreadDelegate.inferiBooksPageSpread(spineIndex, numSpineItems);22 expect(pageSpreadClass).toBe("right_page");23 });24 it("assigns left_page to an odd-numbered page", function () {25 26 var spineIndex = 3;27 var numSpineItems = 10;28 var pageSpreadClass = this.pageSpreadDelegate.inferiBooksPageSpread(spineIndex, numSpineItems);29 expect(pageSpreadClass).toBe("left_page");30 });31 });32 describe("getPageSpreadFromProperties()", function () { 33 beforeEach(function () {34 this.pageSpreadDelegate = new Epub.PageSpreadProperty();35 });36 it("assigns left_page if property is 'left'", function () {37 var pageSpreadProperty = "left";38 var pageSpreadClass = this.pageSpreadDelegate.getPageSpreadFromProperties(pageSpreadProperty);39 expect(pageSpreadClass).toBe("left_page");40 });41 it("assigns right_page if property is 'right'", function () {42 var pageSpreadProperty = "right";43 var pageSpreadClass = this.pageSpreadDelegate.getPageSpreadFromProperties(pageSpreadProperty);44 expect(pageSpreadClass).toBe("right_page");45 });46 it("assigns center_page if property is 'center'", function () {47 48 var pageSpreadProperty = "center";49 var pageSpreadClass = this.pageSpreadDelegate.getPageSpreadFromProperties(pageSpreadProperty);50 expect(pageSpreadClass).toBe("center_page")51 });52 it("assigns '' for all other property values", function () {53 54 var pageSpreadProperty = "unspecified property value";55 var pageSpreadClass = this.pageSpreadDelegate.getPageSpreadFromProperties(pageSpreadProperty);56 expect(pageSpreadClass).toBe("");57 });58 });59 describe("inferUnassignedPageSpread()", function () {60 describe("page-spread is unspecified on all spine items", function () {61 beforeEach(function () {62 var packageDocumentJson = JSON.parse(jasmine.getFixtures().read("package_document_for_page_spread.json"));63 this.packageDocument = new Epub.PackageDocument({ packageDocumentObject : packageDocumentJson });64 this.pageSpreadProperty = new Epub.PageSpreadProperty();65 });66 describe("LTR", function () {67 it("infers first page is left if page prog direction is NOT specified", function () {68 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(0, this.packageDocument.spine, undefined);69 expect(pageSpreadClass).toBe("left_page");70 });71 // Based on fixture with 5 spine items72 it("infers page-1 is left", function () {73 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(0, this.packageDocument.spine, "ltr");74 expect(pageSpreadClass).toBe("left_page");75 });76 it("infers page-2 is right", function () {77 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(1, this.packageDocument.spine, "ltr");78 expect(pageSpreadClass).toBe("right_page");79 });80 it("infers page-3 is left", function () {81 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(2, this.packageDocument.spine, "ltr");82 expect(pageSpreadClass).toBe("left_page");83 });84 it("infers page-4 is right", function () {85 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(3, this.packageDocument.spine, "ltr");86 expect(pageSpreadClass).toBe("right_page");87 });88 it("infers page-5 is left", function () {89 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(4, this.packageDocument.spine, "ltr");90 expect(pageSpreadClass).toBe("left_page");91 });92 });93 describe("RTL", function () {94 // Based on fixture with 5 spine items95 it("infers page-1 is right", function () {96 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(0, this.packageDocument.spine, "rtl");97 expect(pageSpreadClass).toBe("right_page");98 });99 it("infers page-2 is left", function () {100 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(1, this.packageDocument.spine, "rtl");101 expect(pageSpreadClass).toBe("left_page");102 });103 it("infers page-3 is right", function () {104 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(2, this.packageDocument.spine, "rtl");105 expect(pageSpreadClass).toBe("right_page");106 });107 it("infers page-4 is left", function () {108 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(3, this.packageDocument.spine, "rtl");109 expect(pageSpreadClass).toBe("left_page");110 });111 it("infers page-5 is right", function () {112 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(4, this.packageDocument.spine, "rtl");113 expect(pageSpreadClass).toBe("right_page");114 });115 });116 });117 describe("page-spread is specified on SOME spine items", function () {118 beforeEach(function () {119 var packageDocumentJson = JSON.parse(jasmine.getFixtures().read("package_document_for_page_spread_specified.json"));120 this.packageDocument = new Epub.PackageDocument({ packageDocumentObject : packageDocumentJson });121 this.pageSpreadProperty = new Epub.PageSpreadProperty();122 });123 describe("LTR; page-2 == left; page-4 == right", function () {124 // Based on fixture with 5 spine items125 it("infers page-1 is left", function () {126 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(0, this.packageDocument.spine, "ltr");127 expect(pageSpreadClass).toBe("left_page");128 });129 it("infers page-2 is left", function () {130 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(1, this.packageDocument.spine, "ltr");131 expect(pageSpreadClass).toBe("left_page");132 });133 it("infers page-3 is right", function () {134 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(2, this.packageDocument.spine, "ltr");135 expect(pageSpreadClass).toBe("right_page");136 });137 it("infers page-4 is right", function () {138 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(3, this.packageDocument.spine, "ltr");139 expect(pageSpreadClass).toBe("right_page");140 });141 it("infers page-5 is left", function () {142 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(4, this.packageDocument.spine, "ltr");143 expect(pageSpreadClass).toBe("left_page");144 });145 });146 describe("RTL; page-2 == left; page-4 == right", function () {147 // Based on fixture with 5 spine items148 it("infers page-1 is right", function () {149 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(0, this.packageDocument.spine, "rtl");150 expect(pageSpreadClass).toBe("right_page");151 });152 it("infers page-2 is left", function () {153 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(1, this.packageDocument.spine, "rtl");154 expect(pageSpreadClass).toBe("left_page");155 });156 it("infers page-3 is right", function () {157 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(2, this.packageDocument.spine, "rtl");158 expect(pageSpreadClass).toBe("right_page");159 });160 it("infers page-4 is right", function () {161 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(3, this.packageDocument.spine, "rtl");162 expect(pageSpreadClass).toBe("right_page");163 });164 it("infers page-5 is left", function () {165 var pageSpreadClass = this.pageSpreadProperty.inferUnassignedPageSpread(4, this.packageDocument.spine, "rtl");166 expect(pageSpreadClass).toBe("left_page");167 });168 });169 });170 });...
ironCondorFinderTest.js
Source:ironCondorFinderTest.js
1/* eslint-disable no-unused-expressions */2import { expect } from 'chai';3import ironCondorFinder from '../../../src/strategies/ironCondorFinder';4describe('ironCondorFinder Tests', () => {5 const optionData = {6 calls: [],7 pugs: [],8 };9 let singleIronCondorCallSideSpreads;10 let singleIronCondorPutSideSpreads;11 let verticalCreditSpreadFinderSpy;12 let spreadConfig;13 let bearCallOptionData;14 let bearCallCreditSpreadFinderSpy;15 let bearCallSpiedVerticalSpreadFinder;16 let bullPutOptionData;17 let bullPutCreditSpreadFinderSpy;18 let bullPutSpiedVerticalSpreadFinder;19 beforeEach(() => {20 singleIronCondorCallSideSpreads = [{21 credit: 2,22 expiration: '16 MAR 18',23 fairAndEquitableCost: 3,24 anchorStrikeProbItm: 15.00,25 risk: 15,26 strikes: '55/60',27 }];28 singleIronCondorPutSideSpreads = [{29 credit: 1.5,30 expiration: '16 MAR 18',31 fairAndEquitableCost: 0.50,32 anchorStrikeProbItm: 7.00,33 risk: 5,34 strikes: '50/45',35 }];36 bearCallCreditSpreadFinderSpy = {};37 bearCallSpiedVerticalSpreadFinder = () => {};38 bullPutCreditSpreadFinderSpy = {};39 bullPutSpiedVerticalSpreadFinder = () => {};40 spreadConfig = {};41 bullPutCreditSpreadFinderSpy = (data, spreadFinder) => {42 bullPutOptionData = data;43 bullPutSpiedVerticalSpreadFinder = spreadFinder;44 return singleIronCondorPutSideSpreads;45 };46 bearCallCreditSpreadFinderSpy = (data, spreadFinder) => {47 bearCallOptionData = data;48 bearCallSpiedVerticalSpreadFinder = spreadFinder;49 return singleIronCondorCallSideSpreads;50 };51 const innerFunc = () => {52 };53 verticalCreditSpreadFinderSpy = (options) => {54 spreadConfig = options;55 return innerFunc();56 };57 });58 describe('when looking for spreads without need for FaE check', () => {59 it('passes the skipFaE check config parameter to the verticalCallSpreadFinder', () => {60 const options = {61 isNormalIronCondor: true,62 };63 ironCondorFinder(64 optionData, bearCallCreditSpreadFinderSpy,65 bullPutCreditSpreadFinderSpy, verticalCreditSpreadFinderSpy, options,66 );67 expect(spreadConfig.skipFaECheck).to.be.true;68 });69 });70 describe('when no iron condors found', () => {71 it('returns an empty array', () => {72 const noIronCondorData = { calls: [], puts: [] };73 singleIronCondorCallSideSpreads[0].credit = 0;74 const ironCondors = ironCondorFinder(75 noIronCondorData, bearCallCreditSpreadFinderSpy,76 bullPutCreditSpreadFinderSpy, verticalCreditSpreadFinderSpy,77 );78 expect(ironCondors).to.have.lengthOf(0);79 });80 });81 describe('when locating call side credit spreads', () => {82 beforeEach(() => {83 ironCondorFinder(84 optionData, bearCallCreditSpreadFinderSpy,85 bullPutCreditSpreadFinderSpy, verticalCreditSpreadFinderSpy,86 );87 });88 it('passes the call option data to the bear call credit spread finder', () => {89 expect(bearCallOptionData).to.equal(optionData.calls);90 });91 it('passes the vertical call credit spread finder to the bear call credit spread finder', () => {92 expect(bearCallSpiedVerticalSpreadFinder).to.equal(verticalCreditSpreadFinderSpy());93 });94 it('sets the In the Money minimum percent to 13%', () => {95 expect(spreadConfig.minProbItmPercent).to.equal(13.00);96 });97 it('sets the In the Money maximum percent to 17%', () => {98 expect(spreadConfig.maxProbItmPercent).to.equal(17.00);99 });100 });101 describe('when locating put side credit spreads', () => {102 beforeEach(() => {103 ironCondorFinder(104 optionData, bearCallCreditSpreadFinderSpy,105 bullPutCreditSpreadFinderSpy, verticalCreditSpreadFinderSpy,106 );107 });108 it('passes the put option data to the bull put credit spread finder', () => {109 expect(bullPutOptionData).to.equal(optionData.puts);110 });111 it('passes the vertical call credit spread finder to the bull put credit spread finder', () => {112 expect(bullPutSpiedVerticalSpreadFinder).to.equal(verticalCreditSpreadFinderSpy());113 });114 it('sets the In the Money minimum percent to 13%', () => {115 expect(spreadConfig.minProbItmPercent).to.equal(13.00);116 });117 it('sets the In the Money maximum percent to 17%', () => {118 expect(spreadConfig.maxProbItmPercent).to.equal(17.00);119 });120 });121 describe('when Iron Condors found', () => {122 let spreads;123 beforeEach(() => {124 spreads = ironCondorFinder(125 optionData, bearCallCreditSpreadFinderSpy,126 bullPutCreditSpreadFinderSpy, verticalCreditSpreadFinderSpy,127 );128 });129 it('returns the credit earned on the trade', () => {130 expect(spreads[0].credit).to.equal(3.5);131 });132 it('returns the expiration date', () => {133 expect(spreads[0].expiration).to.equal('16 MAR 18');134 });135 it('returns the fair and equitable ratio', () => {136 expect(spreads[0].fairAndEquitableRatio).to.equal(1);137 });138 it('returns the strikes', () => {139 expect(spreads[0].strikes).to.equal('55/60/50/45');140 });141 it('returns the fair and equitable cost of the trade', () => {142 expect(spreads[0].fairAndEquitableCost).to.equal(3.50);143 });144 it('returns the risk of the trade per contract sold', () => {145 expect(spreads[0].risk).to.equal(15);146 });147 it('returns the reward risk ratio of the trade per contract sold', () => {148 expect(spreads[0].rewardRiskRatio).to.equal(0.23);149 });150 });...
verticalCreditSpreadFinderTest.js
Source:verticalCreditSpreadFinderTest.js
1import { expect } from 'chai';2import verticalCreditSpreadFinder from '../../../src/strategies/verticalCreditSpreadFinder';3import {4 oneSpreadNonSiblingStrikeData,5 oneSpreadSiblingStrikeData,6 threeSpreadsStrikeData,7 multipleAnchorMultipleSpreadsStrikeData,8 mixedMonthMultipleSpreadsData,9 lowOpenInterestSpreadsData,10} from './data/optionData';11describe('verticalCreditSpreadFinder Tests', () => {12 const isCreditPotentialStrikes = (shortStrike, longStrike) => {13 return longStrike.strike < shortStrike.strike;14 };15 describe('when options specified', () => {16 it('uses the provided minimum In the Money percent', () => {17 const options = {18 minProbItmPercent: 5,19 };20 const verticalSpreads =21 verticalCreditSpreadFinder(options)(oneSpreadNonSiblingStrikeData, isCreditPotentialStrikes);22 expect(verticalSpreads).to.have.lengthOf(2);23 });24 it('uses the provided maximum In the Money percent', () => {25 const options = {26 minProbItmPercent: 50,27 maxProbItmPercent: 75,28 };29 const verticalSpreads =30 verticalCreditSpreadFinder(options)(oneSpreadNonSiblingStrikeData, isCreditPotentialStrikes);31 expect(verticalSpreads).to.have.lengthOf(1);32 });33 it('skips the FaE check when skipFaECheck is true', () => {34 const options = {35 skipFaECheck: true,36 };37 const verticalSpreads =38 verticalCreditSpreadFinder(options)(oneSpreadNonSiblingStrikeData, isCreditPotentialStrikes);39 expect(verticalSpreads).to.have.lengthOf(2);40 });41 });42 describe('when no spreads found meeting entry criteria', () => {43 it('returns and empty array', () => {44 const noSpreadsData = [{45 probItm: 1.00,46 },47 {48 probItm: 1.5,49 }];50 const verticalSpreads = verticalCreditSpreadFinder()(noSpreadsData, isCreditPotentialStrikes);51 expect(verticalSpreads).to.have.lengthOf(0);52 });53 });54 describe('given single valid anchor strike', () => {55 describe('when valid spread found on strikes next to each other', () => {56 it('returns a valid trade-able spread', () => {57 const verticalSpreads = verticalCreditSpreadFinder()(oneSpreadSiblingStrikeData, isCreditPotentialStrikes);58 expect(verticalSpreads).to.have.lengthOf(1);59 });60 });61 describe('when valid spread found on strikes not next to each other', () => {62 it('returns a valid trade-able spread', () => {63 const verticalSpreads = verticalCreditSpreadFinder()(oneSpreadNonSiblingStrikeData, isCreditPotentialStrikes);64 expect(verticalSpreads).to.have.lengthOf(1);65 });66 });67 describe('when multiple valid spreads found for anchor strike', () => {68 it('returns all valid spreads', () => {69 const verticalSpreads = verticalCreditSpreadFinder()(threeSpreadsStrikeData, isCreditPotentialStrikes);70 expect(verticalSpreads).to.have.lengthOf(3);71 });72 });73 });74 describe('given multiple valid anchor strikes', () => {75 it('returns all valid spread combinations', () => {76 const verticalSpreads =77 verticalCreditSpreadFinder()(multipleAnchorMultipleSpreadsStrikeData, isCreditPotentialStrikes);78 expect(verticalSpreads).to.have.lengthOf(7);79 });80 });81 describe('when valid trade-able spread found', () => {82 let verticalSpreads;83 before(() => {84 verticalSpreads = verticalCreditSpreadFinder()(oneSpreadSiblingStrikeData, isCreditPotentialStrikes);85 });86 it('returns the fairAndEquitableValue field set correctly', () => {87 expect(verticalSpreads[0].fairAndEquitableCost).to.equal(4.5);88 });89 it('returns the credit field set correctly', () => {90 expect(verticalSpreads[0].credit).to.equal(8);91 });92 it('returns the fairAndEquitableRatio field set correctly', () => {93 const expectedRatio = parseFloat((8 / 4.5).toFixed(2));94 expect(verticalSpreads[0].fairAndEquitableRatio).to.equal(expectedRatio);95 });96 it('returns the expiration field set correctly', () => {97 expect(verticalSpreads[0].expiration).to.equal('16 MAR 18');98 });99 it('returns the strikes field set correctly', () => {100 expect(verticalSpreads[0].strikes).to.equal('165/150');101 });102 it('returns the anchor strike probability ITM field set correctly', () => {103 expect(verticalSpreads[0].anchorStrikeProbItm).to.equal(30.00);104 });105 it('returns the width of strikes field set correctly', () => {106 expect(verticalSpreads[0].strikeWidth).to.equal(15);107 });108 it('returns the risk of a single contract', () => {109 expect(verticalSpreads[0].risk).to.equal(15);110 });111 it('returns the reward risk ratio of a single contract', () => {112 expect(verticalSpreads[0].rewardRiskRatio).to.equal(0.53);113 });114 });115 describe('given option data with different expiration months', () => {116 it('does not return spreads crossing expiration months', () => {117 const verticalSpreads = verticalCreditSpreadFinder()(mixedMonthMultipleSpreadsData, isCreditPotentialStrikes);118 expect(verticalSpreads).to.have.lengthOf(3);119 });120 });121 describe('when option has too little open interest', () => {122 it('does not return spreads', () => {123 const verticalSpreads = verticalCreditSpreadFinder()(lowOpenInterestSpreadsData, isCreditPotentialStrikes);124 expect(verticalSpreads).to.have.lengthOf(0);125 });126 });...
proper.js
Source:proper.js
1/* eslint-disable no-use-before-define */2import arraySort from 'array-sort';3import parseOptionData from './parser/parseOptionData';4import bullPutSpreadFinder from './strategies/bullPutSpreadFinder';5import bearCallSpreadFinder from './strategies/bearCallSpreadFinder';6import verticalCreditSpreadFinder from './strategies/verticalCreditSpreadFinder';7import ironCondorFinder from './strategies/ironCondorFinder';8const COLUMN_WIDTH = 20;9export default async (cliui, dataFile) => {10 cliui.div(11 {12 text: 'Strategy',13 width: COLUMN_WIDTH,14 },15 {16 text: 'Credit/Debit',17 width: COLUMN_WIDTH,18 },19 {20 text: 'Risk',21 width: COLUMN_WIDTH,22 },23 {24 text: 'Reward/Risk Ratio',25 width: COLUMN_WIDTH,26 },27 {28 text: 'FaE Cost',29 width: COLUMN_WIDTH,30 },31 {32 text: 'FaE Cost Ratio',33 width: COLUMN_WIDTH,34 },35 {36 text: 'Expiration',37 width: COLUMN_WIDTH,38 },39 {40 text: 'Strikes',41 width: COLUMN_WIDTH,42 },43 );44 try {45 const optionData = await parseOptionData(dataFile);46 let bullPutSpreads = bullPutSpreadFinder(optionData.puts, verticalCreditSpreadFinder());47 let bearCallSpreads = bearCallSpreadFinder(optionData.calls, verticalCreditSpreadFinder());48 let fullCreditIronCondors =49 ironCondorFinder(optionData, bearCallSpreadFinder, bullPutSpreadFinder, verticalCreditSpreadFinder);50 let ironCondors = ironCondorFinder(51 optionData,52 bearCallSpreadFinder,53 bullPutSpreadFinder,54 verticalCreditSpreadFinder,55 { isNormalIronCondor: true },56 );57 bullPutSpreads = arraySort(bullPutSpreads, 'rewardRiskRatio', { reverse: true });58 bearCallSpreads = arraySort(bearCallSpreads, 'rewardRiskRatio', { reverse: true });59 fullCreditIronCondors = arraySort(fullCreditIronCondors, 'rewardRiskRatio', { reverse: true });60 ironCondors = arraySort(ironCondors, 'rewardRiskRatio', { reverse: true });61 printCreditSpreads(bullPutSpreads, cliui, 'Bull Put Spread');62 printCreditSpreads(bearCallSpreads, cliui, 'Bear Call Spread');63 printCreditSpreads(ironCondors, cliui, 'Iron Condor');64 printCreditSpreads(fullCreditIronCondors, cliui, 'Full Credit Iron Condor');65 // eslint-disable-next-line no-console66 console.log(cliui.toString());67 } catch (e) {68 console.error(`Something went wrong ${e.message}`);69 throw e;70 }71};72const printCreditSpreads = (spreads, cliui, type) => {73 spreads.forEach((spread) => {74 cliui.div(75 {76 text: type,77 width: COLUMN_WIDTH,78 },79 {80 text: spread.credit.toString(),81 width: COLUMN_WIDTH,82 },83 {84 text: spread.risk.toString(),85 width: COLUMN_WIDTH,86 },87 {88 text: spread.rewardRiskRatio.toString(),89 width: COLUMN_WIDTH,90 },91 {92 text: spread.fairAndEquitableCost.toString(),93 width: COLUMN_WIDTH,94 },95 {96 text: spread.fairAndEquitableRatio.toString(),97 width: COLUMN_WIDTH,98 },99 {100 text: spread.expiration,101 width: COLUMN_WIDTH,102 },103 {104 text: spread.strikes,105 width: COLUMN_WIDTH,106 },107 );108 });...
ironCondorSpreadCalcTest.js
Source:ironCondorSpreadCalcTest.js
1import { expect } from 'chai';2import {3 calculateFairAndEquitableCost,4 calculateMaxRisk,5 filterValidIronCondors,6} from '../../../src/calc/ironCondorSpreadCalc';7describe('ironCondorSpreadCalc Tests', () => {8 describe('when filtering possible iron condors', () => {9 it('returns an empty array if none are valid', () => {10 const callSpread = {11 credit: 0.50,12 fairAndEquitableCost: 1.00,13 anchorStrikeProbItm: 15.00,14 };15 const putSideSpreads = [16 {17 credit: 0.25,18 anchorStrikeProbItm: 15.00,19 },20 {21 credit: 0.15,22 anchorStrikeProbItm: 15.00,23 },24 ];25 const validIronCondors = filterValidIronCondors(callSpread, putSideSpreads);26 expect(validIronCondors).to.have.lengthOf(0);27 });28 });29 describe('when filtering possible iron condors', () => {30 it('returns spreads with total credit greater than fair and equitable cost of trade', () => {31 const callSpread = {32 credit: 1.10,33 fairAndEquitableCost: 1.50,34 };35 const putSideSpreads = [36 {37 credit: 0.80,38 fairAndEquitableCost: 0.35,39 },40 {41 credit: 0.10,42 fairAndEquitableCost: 0.30,43 },44 {45 credit: 0.65,46 fairAndEquitableCost: 0.15,47 },48 ];49 const validIronCondors = filterValidIronCondors(callSpread, putSideSpreads);50 expect(validIronCondors).to.have.lengthOf(2);51 });52 });53 describe('when calculating max risk', () => {54 it('returns the put spread risk when it has the greatest risk', () => {55 const callSpread = {56 risk: 5,57 };58 const putSpread = {59 risk: 10,60 };61 const risk = calculateMaxRisk(callSpread, putSpread);62 expect(risk).to.equal(10);63 });64 it('returns the call spread risk when it has the greatest risk', () => {65 const callSpread = {66 risk: 15,67 };68 const putSpread = {69 risk: 10,70 };71 const risk = calculateMaxRisk(callSpread, putSpread);72 expect(risk).to.equal(15);73 });74 });75 describe('when calculating fair and equitable cost', () => {76 it('returns the sum of the call and put spread FAE costs', () => {77 const callSpread = {78 fairAndEquitableCost: 2.0,79 };80 const putSpread = {81 fairAndEquitableCost: 1.2,82 };83 const faeCost = calculateFairAndEquitableCost(callSpread, putSpread);84 expect(faeCost).to.equal(3.20);85 });86 });...
ironCondorFinder.js
Source:ironCondorFinder.js
1/* eslint-disable no-use-before-define */2import { calculateFairAndEquitableCost, calculateMaxRisk, filterValidIronCondors } from '../calc/ironCondorSpreadCalc';3export default (4 optionData,5 bearCallCreditSpreadFinder,6 bullPutCreditSpreadFinder,7 verticalCreditSpreadFinder,8 options,9) => {10 const spreadCalcConfigOptions = {11 minProbItmPercent: 13.00,12 maxProbItmPercent: 17.00,13 skipFaECheck: !!(options && options.isNormalIronCondor),14 };15 const configuredVerticalCreditSpreadFinder = verticalCreditSpreadFinder(spreadCalcConfigOptions);16 const callSideSpreads = bearCallCreditSpreadFinder(optionData.calls, configuredVerticalCreditSpreadFinder);17 const putSideSpreads = bullPutCreditSpreadFinder(optionData.puts, configuredVerticalCreditSpreadFinder);18 let allIronCondors = [];19 callSideSpreads.forEach((callSpread) => {20 const ironCondorsForCall = filterValidIronCondors(callSpread, putSideSpreads);21 ironCondorsForCall.forEach((putSpread) => {22 const faeCost = calculateFairAndEquitableCost(callSpread, putSpread);23 const totalCredit = callSpread.credit + putSpread.credit;24 const totalRisk = calculateMaxRisk(callSpread, putSpread);25 const ironCondor = {26 credit: totalCredit,27 expiration: callSpread.expiration,28 fairAndEquitableCost: faeCost,29 fairAndEquitableRatio: parseFloat((totalCredit / faeCost).toFixed(2)),30 rewardRiskRatio: parseFloat((totalCredit / totalRisk).toFixed(2)),31 risk: totalRisk,32 strikes: `${callSpread.strikes}/${putSpread.strikes}`,33 };34 allIronCondors = [...allIronCondors, ironCondor];35 });36 });37 return allIronCondors;...
ironCondorSpreadCalc.js
Source:ironCondorSpreadCalc.js
1/* eslint-disable no-use-before-define */2export const filterValidIronCondors = (anchorSpread, testSpreads) => {3 const validIronCondors = testSpreads.filter((testSpread) => {4 const cost = calculateFairAndEquitableCost(anchorSpread, testSpread);5 return (testSpread.credit + anchorSpread.credit) >= cost;6 });7 return validIronCondors;8};9export const calculateFairAndEquitableCost = (callSpread, putSpread) => {10 const faeCost = callSpread.fairAndEquitableCost + putSpread.fairAndEquitableCost;11 return parseFloat(faeCost.toFixed(2));12};13export const calculateMaxRisk = (callSpread, putSpread) => {14 let maxRisk;15 if (callSpread.risk > putSpread.risk) {16 maxRisk = callSpread.risk;17 } else {18 maxRisk = putSpread.risk;19 }20 return maxRisk;...
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6describe('My First Test', function() {7 it('Does not do much!', function() {8 expect(true).to.equal(true)9 })10})11describe('My First Test', function() {12 it('Does not do much!', function() {13 expect(true).to.equal(true)14 })15})16describe('My First Test', function() {17 it('Does not do much!', function() {18 expect(true).to.equal(true)19 })20})
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 expect(true).to.equal(true)4 })5})6describe('My Second Test', () => {7 it('Visits the Kitchen Sink', () => {8 })9})10describe('My Third Test', () => {11 it('Finds an element', () => {12 cy.contains('type').click()13 })14})15describe('My Fourth Test', () => {16 it('Gets, types and asserts', () => {17 cy.contains('type').click()18 cy.url().should('include', '/commands/actions')19 cy.get('.action-email')20 .type('
Using AI Code Generation
1const { default: _ } = require("lodash");2describe('My First Test', function() {3 it('Does not do much!', function() {4 cy.get('.search-keyword').type('ca');5 cy.wait(2000);6 cy.get('.products').as('productLocator')7 cy.get('@productLocator').find('.product').should('have.length',4)8 cy.get(':nth-child(3) > .product-action > button').click()9 cy.get('@productLocator').find('.product').should('have.length',3)10 cy.get('@productLocator').find('.product').eq(2).contains('ADD TO CART').click().then(function(){11 console.log('sf')12 })13 cy.get('@productLocator').find('.product').each(($el, index, $list) => {14 const textVeg=$el.find('h4.product-name').text()15 if(textVeg.includes('Cashews')){16 $el.find('button').click()17 }18 })19 cy.get('.brand').should('have.text','GREENKART')20 cy.get('.brand').then(function(logoelement){21 cy.log(logoelement.text())22 })23 cy.get('.brand').should('have.class', 'brand-green')24 cy.get('.brand').then(function(logoelement){25 cy.log(logoelement.text())26 })27 cy.get('.brand').should('have.class', 'brand-green')28 cy.get('.brand').then(function(logoelement){
Using AI Code Generation
1const { expect } = require("chai");2describe("Spread Operator", () => {3 it("Should spread an array", () => {4 let arr1 = [1, 2, 3, 4, 5];5 let arr2 = [6, 7, 8, 9, 10];6 let arr3 = [...arr1, ...arr2];7 expect(arr3).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);8 });9 it("Should spread an object", () => {10 let obj1 = { key1: "value1", key2: "value2" };11 let obj2 = { key3: "value3", key4: "value4" };12 let obj3 = { ...obj1, ...obj2 };13 expect(obj3).to.deep.equal({14 });15 });16});
Using AI Code Generation
1Cypress.Commands.add("spread", (selector, options = {}) => {2 cy.get(selector, options).then(($element) => {3 return Cypress._.spread($element);4 });5});6Cypress.Commands.add("getByTestId", (selector, options = {}) => {7 return cy.get(`[data-testid=${selector}]`, options);8});9Cypress.Commands.add("getByTestId", (selector, options = {}) => {10 return cy.get(`[data-testid=${selector}]`, options);11});12Cypress.Commands.add("getByTestId", (selector, options = {}) => {13 return cy.get(`[data-testid=${selector}]`, options);14});15Cypress.Commands.add("getByTestId", (selector, options = {}) => {16 return cy.get(`[data-testid=${selector}]`, options);17});18Cypress.Commands.add("getByTestId", (selector, options = {}) => {19 return cy.get(`[data-testid=${selector}]`, options);20});21Cypress.Commands.add("getByTestId", (selector, options = {}) => {22 return cy.get(`[data-testid=${selector}]`, options);23});
Using AI Code Generation
1import {add} from './math.js'2const result = add(1, 2);3expect(result).to.equal(3);4import {add} from './math.js'5const result = add(1, 2);6expect(result).to.equal(3);7import {add} from './math.js'8const result = add(1, 2);9expect(result).to.equal(3);10import {add} from './math.js'11const result = add(1, 2);12expect(result).to.equal(3);13import {add}
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!