Advertisement
Guest User

rgbToHex

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("rgbToHexColor(red,green,blue)", function () {
  2.     describe("Nominal cases(valid input)", function () {
  3.         it("should return #FF9EAA for (255, 158, 170)", function () {
  4.             let color = rgbToHexColor(255, 158, 170);
  5.             expect(color).equal("#FF9EAA");
  6.         });
  7.  
  8.         it("should return #000000 for (0, 0, 0)", function () {
  9.             let color = rgbToHexColor(0, 0, 0);
  10.             expect(color).equal("#000000");
  11.         });
  12.  
  13.         it("should return #0C0D0E for (12, 13, 14)", function () {
  14.             let color = rgbToHexColor(12, 13, 14);
  15.             expect(color).equal("#0C0D0E");
  16.         });
  17.  
  18.         it("should return #FFFFFF for (255, 255, 255)", function () {
  19.             let color = rgbToHexColor(255, 255, 255);
  20.             expect(color).equal("#FFFFFF");
  21.         })
  22.     });
  23.  
  24.     describe("Special cases(invalid input)", function () {
  25.         it("should return undefined for negative red value", function () {
  26.             let color = rgbToHexColor(-1, 255, 255);
  27.             expect(color).equal(undefined);
  28.         });
  29.  
  30.         it("should return undefined for negative green value", function () {
  31.             let color = rgbToHexColor(255, -1, 255);
  32.             expect(color).equal(undefined);
  33.         });
  34.  
  35.         it("should return undefined for negative blue value", function () {
  36.             let color = rgbToHexColor(255, 255, -1);
  37.             expect(color).equal(undefined);
  38.         });
  39.  
  40.         it("should return undefined for too big red value",function () {
  41.             let color = rgbToHexColor(256,255,255);
  42.             expect(color).equal(undefined);
  43.         });
  44.  
  45.         it("should return undefined for too big green value",function () {
  46.             let color = rgbToHexColor(255,256,255);
  47.             expect(color).equal(undefined);
  48.         });
  49.  
  50.         it("should return undefined for too big blue value",function () {
  51.             let color = rgbToHexColor(255,255,256);
  52.             expect(color).equal(undefined);
  53.         });
  54.  
  55.         it("should return undefined for non integer red value", function () {
  56.             let color = rgbToHexColor(13.5,100,100);
  57.             expect(color).equal(undefined);
  58.         });
  59.  
  60.         it("should return undefined for non integer green value", function () {
  61.             let color = rgbToHexColor(100,13.5,100);
  62.             expect(color).equal(undefined);
  63.         });
  64.  
  65.         it("should return undefined for non integer blue value", function () {
  66.             let color = rgbToHexColor(100,100,13.5);
  67.             expect(color).equal(undefined);
  68.         });
  69.  
  70.         it("should return undefined for non number values", function () {
  71.             let color = rgbToHexColor('red',[3],{5:8});
  72.             expect(color).equal(undefined);
  73.         });
  74.  
  75.         it("should return undefined for missing parameters", function () {
  76.             let color = rgbToHexColor();
  77.             expect(color).equal(undefined);
  78.         })
  79.     })
  80. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement