style attribute javascript angularjs typescript jasmine mocha

javascript - attribute - title html



error que ocurre después de agregar un nuevo parámetro (3)

Creo que _dataSource no está configurado correctamente, por lo tanto, no puedes acceder a su array _data

Tuve un caso de prueba funcionando bien, pero después de agregar un parámetro adicional de tiger a mi método de swiming , se está rompiendo.

Incluso pasé el nuevo parámetro tiger a mi caso de prueba, pero aún se está rompiendo.

actualización Estoy obteniendo una grilla indefinida en esta línea ... cualquier idea ahora de cómo proceder permite que grid = $ (''# henTigerGrid''). data (''kendoGrid'');

let tiger = { "nail": "hens/v1/sky/88888888888888", "columns": [], "title": "DOCUMENTS", "excelFileName": "ViewAiringsExport", "mainId": 88888888888888 };

El código está abajo:

Error

[0] 14 09 2017 19:56:26.250:DEBUG [web-server]: serving (cached): C:/Desktop/08-31-afternoon/webcomponent/src/main/webapp/app/components/finan LOG: ''model.skyName--->text.txt'' LOG: ''tiger.naile---->hens/v1/sky/88888888888888'' Chrome 60.0.3112 (Windows 10 0.0.0) Jasmine Unit Tests: Help-Dashboard-Manage-Tiger Add start Finger FAILED [0] TypeError: Cannot read property ''_data'' of undefined Chrome 60.0.3112 (Windows 10 0.0.0): Executed 14 of 29 (1 FAILED) (0 secs / 2.796 secs)

Código

swiming(evt, dropValue, tiger) { let todayDate = this.todayDate(); let grid = $(''#henTigerGrid'').data(''kendoGrid''); let _dataSource = grid.dataSource; let pageSize = _dataSource.pageSize(); //console.log("_dataSource._data---->" + _dataSource._data.length); let gridLength = _dataSource._data.length; let filename; console.log("loggedUserName---->" + $(".loggedUserName").text()); let attributes=this.sportsService.getSeesionStorageValue(); if(attributes) { this.parrotrId = attributes.parrotr_attributes.SSO[0]; this.loggedUserName = attributes.parrotr_attributes.DisplayName[0]; } if(this.fileSelect == null || this.fileSelect == "") { _dataSource.insert(gridLength, { "skyId": "104", "skyName": filename, }); } else { let temparry = []; let attributes = this.sportsService.getSeesionStorageValue(); let lastIndex = this.fileSelect.lastIndexOf("."); if(lastIndex >= 0) { filename = this.fileSelect; //.substring(lastIndex,0); } var fileSize = 0; fileSize = fileSize / 1048576; //size in mb let k = _dataSource._data.length; _dataSource.insert(k, { "skyId": "105", "skyName": filename, }); //temparry.push(data) let skyData = {}; //skyData["gridData"] = data; this.dragDrop = ""; this.dragDrop = this.clearBtn; $("#attachFingerBrowseBtn").val(''''); this.fileSelect = ""; let data_source = _dataSource.data(); for(let d = 0; d < data_source.length; d++) { if(data_source[d].isElfDoc == true && data_source[d].sublimeDocID == "") { //this.gridkendo.enableSaveFinger(false); } } } $(''.addSkipingerForm'').hide(); let permissionDto = ""; let functionalList = ""; if(true) { let currentData = _dataSource._data; // console.log("filename---->" + filename); console.log("tiger.naile---->" + tiger.nail); //this.selectedFingerId=tiger.nail; this.selectedFingerId=tiger.nail; // var str = "hens/v1/sky/35369"; var strx = this.selectedFingerId; var res = strx.substring(23); let attributes = this.sportsService.getSeesionStorageValue(); if(attributes) { this.parrotrId = attributes.parrotr_attributes.SSO[0]; this.loggedUserName = attributes.parrotr_attributes.DisplayName[0]; } let compassUser = this.parrotrId; // console.log("this.parrotrId---->" + this.parrotrId); // console.log("this.parrotrId---->" + this.loggedUserName); //"skyId": this._dataSource._data.length+1, let records = [ { "id": res, "skyDtos" : [{ "skyId": this._dataSource._data.length + 1, "skyName": filename, "operationType": "create", }] } ]; for(let i = 0; i < currentData.length; i++) { if(currentData[i].skyId == "") { } } for(let i = 0; i < _dataSource._destroyed.length; i++) { } this.sportsService .getResponse("hens/v1/sky/", "post", records[0]) .subscribe(data => { console.log("data---->" + data); if (data.code == ''S001'') { } else { } }, err => { } ); } $(''.k-pager-numbers li'').last().find(''a'').click(); }

Caso de prueba

describe(''Jasmine Unit Tests: Help-Dashboard-Manage-Tiger'', () => { let detailsportsService:SPORTSService; let sportsService: SPORTSService; let decodeService: DecodeService; let fish: HelpDashboardContract; let henViewDetailsComponent: startViewDetails; let scroll: ComponentFixture<HelpDashboardContract>; let detailscroll: ComponentFixture<startViewDetails>; let debuggerscroll: ComponentFixture<NetworkCaroparrotl>; let kendoscroll: ComponentFixture<KendoGridComponent>; let debuggerComponent:NetworkCaroparrotl; let kendoComponent:KendoGridComponent; beforeEach(async(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; TestBed.configureTestingModule({ imports: [HttpModule, FormsModule,BrowserModule ], declarations:[HelpDashboardContract, KendoGridComponent,ProgressCircle, startViewDetails,HelpLeftSliderComponent,NetworkCaroparrotl,startTiger], providers:[SPORTSService,DecodeService,recentPinnedHistoryService, {provide: Router, parrotClass: RouterModule}, validationService,saveService, contractService] }).compileComponents().then(() =>{ debuggerscroll = TestBed.createComponent(NetworkCaroparrotl); kendoscroll = TestBed.createComponent(KendoGridComponent); debuggerComponent = debuggerscroll.componentInstance; kendoComponent = kendoscroll.componentInstance; scroll = TestBed.createComponent(HelpDashboardContract); fish = scroll.componentInstance; sportsService = scroll.debugElement.injector.get(SPORTSService); scroll.componentInstance.startTiger.sportsService=scroll.debugElement.injector.get(SPORTSService); scroll.componentInstance.startViewDetails.sportsService=scroll.debugElement.injector.get(SPORTSService); decodeService = scroll.debugElement.injector.get(DecodeService); fish.inputNetworkCaroparrotl = debuggerComponent; //jasmine.createSpy(''NetworkCaroparrotl'');//.andCallFake(function(msg) { return this }); fish.startTiger.gridkendo=kendoComponent; })} )); it(''Add start Finger'', (done) => { let callFirstTime : boolean = true; let nail = spyOn(fish.startTiger.sportsService,''getResponse'').and.callFake(() => { if(callFirstTime) { callFirstTime = false; // Invoked by detectChanges() return Observable.of([{ "skyId": "100", "skyName": "http://localhost:3000/assets/js/actualairings.json", "skyType": "TITLE", "operationType": "create" }, { "skyId": "101", "skyName": "example.pdf", "parrotrID": "dad", "operationType": "create" }, { "skyId": "101", "skyName": "example.ppt", "parrotrID": "dad", "operationType": "create" }] ); } }); spyOn(fish.startTiger.gridkendo,''enableSaveFinger'').and.returnValue(null); //spyOn(fish.startTiger.gridkendo._dataSource,'''').and.returnValue(null); //fish.startTiger.gridkendo._dataSource._data.length =''''; fish.startTiger.fileSelect = "text.txt"; let tiger = { "nail": "hens/v1/sky/88888888888888", "columns": [], "title": "DOCUMENTS", "excelFileName": "ViewAiringsExport", "mainId": 88888888888888 }; //fish.startTiger.swiming('''', '''', ''''); fish.startTiger.swiming('''', '''', tiger); scroll.whenStable().then(() => { done(); expect(fish.startTiger._dataSource._data.length).toEqual(3); }); }); });


En su función utiliza una búsqueda jQuery $(''#henTigerGrid'').data(''kendoGrid''); para un elemento con id #henTigerGrid que no está definido en la prueba de unidad proporcionada. Algunas líneas debajo de ti intentan acceder a una propiedad _data de la búsqueda que luego falla.

Este es un ejemplo típico del uso incorrecto de un patrón de localizador de servicios (lo que esencialmente son las búsquedas de jQuery). Introducen dependencias ocultas, sin tipo que te piquen más tarde (mira tu problema actual). Si utilizara un estilo de inyección de dependencia más, el valor de los atributos (o el propio elemento Dom) se pasará como una dependencia (aquí un parámetro declarado) a la función. Al igual que el error podría incluso ocurrir en primer lugar, ya que no se perderá un parámetro faltante.


hey, encontré que si elimino esta línea, el error se está reparando

"skyId": this._dataSource._data.length + 1,