Advertisement
DennyGD

tests CSSExamApril2014 Task1

May 10th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.runBeforeTests = function() {
  2.     $("body").css("padding", "0");
  3.     $("body").css("margin", "0");
  4.     $("html").css("padding", "0");
  5.     $("html").css("margin", "0");
  6.     $("#wrapper").css("padding", "0");
  7.     $("#wrapper").css("margin", "0");
  8. }
  9.  
  10. exports.tests = [
  11.     // Font sizes
  12.     {name:"Font size of the title", points: 4, func:function(){
  13.         return $("header>h1").css("font-size");
  14.     }, expected: "16px", compare: "equal", compareParam: null},
  15.    
  16.     {name:"Font size of the menu", points: 4, func:function(){
  17.         return $("#nav>ul>li").css("font-size");
  18.     }, expected: "14px", compare: "equal", compareParam: null},
  19.    
  20.     {name:"Font size of the archive", points: 3, func:function(){
  21.         return $("#archives>a").css("font-size");
  22.     }, expected: "14px", compare: "equal", compareParam: null},
  23.    
  24.     {name:"Font size of the search", points: 3, func:function(){
  25.         return $("#search>a").css("font-size");
  26.     }, expected: "14px", compare: "equal", compareParam: null},
  27.    
  28.     {name:"Font size of the content title", points: 4, func:function(){
  29.         return $("#content>h1").css("font-size");
  30.     }, expected: "24px", compare: "equal", compareParam: null},
  31.    
  32.     {name:"Font size of the content", points: 4, func:function(){
  33.         return $("#content>article>p").css("font-size");
  34.     }, expected: "14px", compare: "equal", compareParam: null},
  35.    
  36.    
  37.     // Colors
  38.     {name:"Title text color difference", points: 3, func:function(){
  39.         return $.xcolor.distance($("header>h1").css("color"), "#575E5B");
  40.     }, expected: 0, compare: "equalDiff", compareParam: 60},
  41.        
  42.     {name:"Menu text color difference", points: 2, func:function(){
  43.         return $.xcolor.distance($("#nav>ul>li").css("color"), "#575E5B");
  44.     }, expected: 0, compare: "equalDiff", compareParam: 60},
  45.        
  46.     {name:"Archive text color difference", points: 3, func:function(){
  47.         return $.xcolor.distance($("#archives>a").css("color"), "#C6C6C6");
  48.     }, expected: 0, compare: "equalDiff", compareParam: 60},
  49.        
  50.     {name:"Search text color difference", points: 2, func:function(){
  51.         return $.xcolor.distance($("#search>a").css("color"), "#C6C6C6");
  52.     }, expected: 0, compare: "equalDiff", compareParam: 60},
  53.        
  54.     {name:"Content title text color difference", points: 3, func:function(){
  55.         return $.xcolor.distance($("#content>h1").css("color"), "#575E5B");
  56.     }, expected: 0, compare: "equalDiff", compareParam: 60},
  57.        
  58.     {name:"Content text color difference", points: 2, func:function(){
  59.         return $.xcolor.distance($("#content>article>p").css("color"), "#575E5B");
  60.     }, expected: 0, compare: "equalDiff", compareParam: 60},
  61.    
  62.    
  63.     // Page
  64.     {name:"No padding or margin at the start of the page", points: 2, func:function(){
  65.         return $("header").offset().top;
  66.     }, expected: 0, compare: "equal", compareParam: null},
  67.    
  68.    
  69.     // Header
  70.     {name:"Header height", points: 5, func:function(){
  71.         return $("header").outerHeight() - parseInt($("header").css("border-bottom-width"));
  72.     }, expected: 49, compare: "equalDiff", compareParam: 2},
  73.    
  74.     {name:"Header has background image", points: 4, func:function(){
  75.         return $("header").css("background-image").indexOf("header-bg.png") > -1;
  76.     }, expected: true, compare: "equal", compareParam: null},
  77.    
  78.    
  79.     // Header title
  80.     {name:"Header title left offset is correct", points: 4, func:function(){
  81.         return $("header>h1").offset().left
  82.             + parseInt($("header>h1").css("padding-left"));
  83.     }, expected: 15, compare: "equalDiff", compareParam: 2},
  84.    
  85.     {name:"Header title top offset is correct", points: 4, func:function(){
  86.         return $("header>h1").offset().top
  87.             + parseInt($("header>h1").css("padding-top"));
  88.     }, expected: 15, compare: "equalDiff", compareParam: 2},
  89.    
  90.     {name:"Header title is uppercased", points: 4, func:function(){
  91.         return $("header>h1").css("text-transform").indexOf("uppercase") > -1;
  92.     }, expected: true, compare: "equal", compareParam: null},
  93.    
  94.    
  95.     // Menu (navigation)
  96.     {name:"Menu is right floated", points: 5, func:function(){
  97.         return $("#nav>ul>li").eq(0).offset().left;
  98.             + parseInt($("#nav>ul>li").eq(0).css("padding-left"));
  99.     }, expected: 712, compare: "equalDiff", compareParam: 50},
  100.    
  101.     {name:"Menu top offset is correct", points: 4, func:function(){
  102.         return $("#nav>ul>li").eq(0).offset().top
  103.             + parseInt($("#nav>ul>li").eq(0).css("padding-top"));
  104.     }, expected: 17, compare: "equalDiff", compareParam: 2},
  105.    
  106.     {name:"Distance between two menu links", points: 4, func:function(){
  107.         var a1 = $("#nav>ul>li").eq(0).offset().left;
  108.         var a2 = $("#nav>ul>li").eq(1).offset().left;
  109.         return Math.abs(a1 - a2);
  110.     }, expected: 57, compare: "equalDiff", compareParam: 5},
  111.    
  112.     {name:"Two menu links are on the same line", points: 5, func:function(){
  113.         var a1 = $("#nav>ul>li").eq(0).offset().top;
  114.         var a2 = $("#nav>ul>li").eq(1).offset().top;
  115.         return Math.abs(a1 - a2);
  116.     }, expected: 0, compare: "equal", compareParam: null},
  117.    
  118.    
  119.     // Search bar and archive
  120.     {name:"searchBar has black background color", points: 4, func:function(){
  121.         return $.xcolor.distance($("#searchBar").css("background-color"), "#000000");
  122.     }, expected: 0, compare: "equalDiff", compareParam: 15},
  123.    
  124.     {name:"Horizontal offset between archive links and searchBar", points: 3, func:function(){
  125.         var a1 = $("#searchBar").offset().top;
  126.         var a2 = $("#archives>a").eq(0).offset().top;
  127.         return Math.abs(a1 - a2);
  128.     }, expected: 10, compare: "equalDiff", compareParam: 2},
  129.    
  130.     {name:"Vertical offset between archive links and searchBar", points: 3, func:function(){
  131.         var a1 = $("#searchBar").offset().left;
  132.         var a2 = $("#archives>a").eq(0).offset().left;
  133.         return Math.abs(a1 - a2);
  134.     }, expected: 19, compare: "equalDiff", compareParam: 2},
  135.    
  136.     {name:"Archive links and search text are on the same line", points: 4, func:function(){
  137.         var a1 = $("#archives>a").eq(0).offset().top;
  138.         var a2 = $("#search>a").offset().top;
  139.         return Math.abs(a1 - a2);
  140.     }, expected: 0, compare: "equal", compareParam: null},
  141.  
  142.     {name:"Archive links are not underlined", points: 4, func:function(){
  143.         return $("#archives>a").css("text-decoration").indexOf("none") > -1;
  144.     }, expected: true, compare: "equal", compareParam: null},
  145.    
  146.     {name:"Search is right floated", points: 4, func:function(){
  147.         return $("#search>a").offset().left;
  148.     }, expected: 911, compare: "equalDiff", compareParam: 50},
  149. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement