Upload
valtech-ab
View
103
Download
3
Embed Size (px)
DESCRIPTION
Janko Luin berättar om hur man tester JavaScript.
Citation preview
Testning av JavaScriptJanko Luin
@gufo
$("body").append( $("<div>").text(firstName + " " + lastName));
<div class="person"> {{firstName}} {{lastName}}</div>
$("body").append( $("<div>").text(firstName + " " + lastName));
<div class="person"> {{firstName}} {{lastName}}</div>
function showListOf(people) { $.dropdown(people);}
function showListOf(people, dropdown) { dropdown(people);}
// ImplementationshowListOf(people, $.dropdown);
// TestfakeDropdown = function() { droppedDown = true; }showListOf(people, fakeDropdown);expect(droppedDown).toEqual(true);
function showListOf(people) { $.dropdown(people);}
function showListOf(people, dropdown) { dropdown(people);}
// ImplementationshowListOf(people, $.dropdown);
// TestfakeDropdown = function() { droppedDown = true; }showListOf(people, fakeDropdown);expect(droppedDown).toEqual(true);
function showListOf(people) { $.dropdown(people);}
function showListOf(people, dropdown) { dropdown(people);}
// ImplementationshowListOf(people, $.dropdown);
// TestfakeDropdown = function() { droppedDown = true; }showListOf(people, fakeDropdown);expect(droppedDown).toEqual(true);
function setupDropdown() { $(".dropdown").on("click", function() { // Perform acts of magic });}
// ImplementationsetupDropdown($(".dropdown"));
// Testvar trigger = $("<div>");setupDropdown(trigger);
function setupDropdown(element) { $(element).on("click", function() { // Perform acts of magic });}
// ImplementationsetupDropdown($(".dropdown"));
// Testvar trigger = $("<div>");setupDropdown(trigger);
Nivåer av testerEnhetstest / acceptanstest
HTML och jQueryIsolera så långt som möjligt
Komma igångAcceptanstester först - lyssna på testerna!
Bilder (Flickr / CC-Attrib):
• walkn - "DVD Player Outputs"
• pasukaru76 - "The Mess"
• crd - "An Old Faithful Sign - Yellowstone National Park"
• glaciernps - "Plowing in Oberlin Bend."