Sono nuovo al banco di prova gelsomini ho cercato di fare banco di prova per il gelsomino modulo di selezione dopo aver fatto questa struttura in stile sta diventando indefinitoCome fare test case gelsomino per la proprietà di visualizzazione nessuno css usando documet.getElementById e getElementsByClassName
function Selection() {
}
Selection.prototype.expandFlightDetails = function() {
document.getElementsByClassName("flight-details-container").style.display = 'none';
document.getElementById("expandedFlightDetails").style.display = 'block';
};
Selection.prototype.hideFlightDetails = function() {
document.getElementById("expandedFlightDetails").style.display = 'none';
document.getElementsByClassName("flight-details-container").style.display = 'block';
};
mio testcase è
describe("selection module", function() {
var selection;
beforeEach(function() {
selection= new Selection();
});
afterEach(function() {
});
it('expand the flight details part ' , function(){
selection.expandFlightDetails();
expect(document.body.getElementsByClassName('flight-details-container')[0].style.display).toEqual('none');
});
xit('hide the flight details part ', function(){
selection.hideFlightDetails();
expect(document.getElementById('expandedFlightDetails').style.display).toEqual('none');
});
});
Dopo aver fatto questo che sto geting e rimosso il codice per beforEach
TypeError: Cannot read property 'style' of undefined
per favore correggimi se ho sbagliato
proprietà 'style' che hai usato così tante volte? dove è arrivato questo errore? –
@VikrantKashyap it ('espandi la parte dei dettagli del volo', function() { flightselection.expandFlightDetails(); expect (document.body.getElementsByClassName ('flight-details-container') [0] .style.display). toqual ('none'); }); per questo caso ho riscontrato questo errore –
Stai includendo il file html che sta avendo un elemento con la classe "flight-details-container". ? – rajesh