<commit_before>////////////////////////////////////////////////////////////////////////////////

QUnit.test("2x high-res image call.", function(assert) {

  //////////
  // Given

  var ip = new ImgTagBuilder({ styles: { main: { breakPoints: [ { minViewportWidth: 0, maxImageDisplayWidth: 800, quality: 85 } ] } } });
  
  //////////
  // When

  ip._devicePixelRatio = 2; // Force to '2' so testing works across devices.
  ip.innerWidth = 1000; // Force for testing regardless of device. 

  ip.prep({ image: "horses.jpg", alt: "some horses",  style: "main", maxWidth: 1600, maxHeight: 1000 });


  //////////
  // Then

  // This is the key requirement. Everything else supports it.
  assert.equal(ip.imgTag(),'<img alt="some horses" class="main" width="800" height="500" src="http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_1600,h_1000/horses.jpg">', "Target `img` tag."); 

  // Verify config details are ingested.
  assert.equal(ip._alt, "some horses", "_alt");
  assert.equal(ip._image, "horses.jpg", "_image");
  assert.equal(ip._maxHeight, 1000, "_maxHeight");
  assert.equal(ip._maxWidth, 1600, "_maxWidth");
  assert.equal(ip._devicePixelRatio, 2, "_devidePixelRatio");
  assert.equal(ip._style, "main", "_style");
  
  // TODO: Figure out how to move this out so it's called dynamically.
  assert.equal(ip._config.styles['main']['breakPoints'][0]['maxImageDisplayWidth'], 800, "maxImageDisplayWidth");

  // Method verification 
  assert.equal(ip.callHeight(), 1000, "callHeight()");
  assert.equal(ip.callWidth(), 1600, "callWidth()");
  assert.equal(ip.displayHeight(), 500, "displayHeight()");
  assert.equal(ip.displayWidth(), 800, "displayWidth()");
  assert.equal(ip.url(),'http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_1600,h_1000/horses.jpg', "url()"); 
  assert.equal(ip.quality(), 85, "quality()");
  assert.equal(ip.ratio(), 0.625, "ratio()");

});

////////////////////////////////////////////////////////////////////////////////

QUnit.test("Verify window.devicePixelRatio is pulled in", function(assert) {

	// The other tests force an override to ensure the math works regardless of 
	// the browser being tested. This one just makes sure the data is loaded 
	// normally. 

  
  ///////////
  // Given

  var ip = new ImgTagBuilder({});

  //////////
  // Then

  assert.equal(ip._devicePixelRatio, window.devicePixelRatio, "_devicePixelRatio");

});


////////////////////////////////////////////////////////////////////////////////

QUnit.test("Pick the larger of two config options (in decending order) based on innerWidth", function(assert) {

  //////////
  // Given

  var breakAlpha = { minViewportWidth: 900, maxImageDisplayWidth: 800, quality: 85 };
  var breakBravo = { minViewportWidth: 0, maxImageDisplayWidth: 400, quality: 85 };

  var ip = new ImgTagBuilder({ styles: { main: { breakPoints: [ breakAlpha, breakBravo ] } } });

  //////////
  // When

  ip._devicePixelRatio = 2; // Force to '2' so testing works across devices.
  ip.innerWidth = 1000; // Force for testing regardless of device. 

  ip.prep({ image: "horses.jpg", alt: "some horses",  style: "main", maxWidth: 1600, maxHeight: 1000 });


  //////////
  // Then

  // This is the key requirement. Everything else supports it.
  assert.equal(ip.imgTag(),'<img alt="some horses" class="main" width="800" height="500" src="http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_1600,h_1000/horses.jpg">', "Target `img` tag"); 


});



<commit_msg>Corrected "_innerWidth" in test3 and added test4 for the second breakpoint.<commit_after>////////////////////////////////////////////////////////////////////////////////

QUnit.test("2x high-res image call.", function(assert) {

  //////////
  // Given

  var ip = new ImgTagBuilder({ styles: { main: { breakPoints: [ { minViewportWidth: 0, maxImageDisplayWidth: 800, quality: 85 } ] } } });
  
  //////////
  // When

  ip._devicePixelRatio = 2; // Force to '2' so testing works across devices.
  ip.innerWidth = 1000; // Force for testing regardless of device. 

  ip.prep({ image: "horses.jpg", alt: "some horses",  style: "main", maxWidth: 1600, maxHeight: 1000 });


  //////////
  // Then

  // This is the key requirement. Everything else supports it.
  assert.equal(ip.imgTag(),'<img alt="some horses" class="main" width="800" height="500" src="http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_1600,h_1000/horses.jpg">', "Target `img` tag."); 

  // Verify config details are ingested.
  assert.equal(ip._alt, "some horses", "_alt");
  assert.equal(ip._image, "horses.jpg", "_image");
  assert.equal(ip._maxHeight, 1000, "_maxHeight");
  assert.equal(ip._maxWidth, 1600, "_maxWidth");
  assert.equal(ip._devicePixelRatio, 2, "_devidePixelRatio");
  assert.equal(ip._style, "main", "_style");
  
  // TODO: Figure out how to move this out so it's called dynamically.
  assert.equal(ip._config.styles['main']['breakPoints'][0]['maxImageDisplayWidth'], 800, "maxImageDisplayWidth");

  // Method verification 
  assert.equal(ip.callHeight(), 1000, "callHeight()");
  assert.equal(ip.callWidth(), 1600, "callWidth()");
  assert.equal(ip.displayHeight(), 500, "displayHeight()");
  assert.equal(ip.displayWidth(), 800, "displayWidth()");
  assert.equal(ip.url(),'http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_1600,h_1000/horses.jpg', "url()"); 
  assert.equal(ip.quality(), 85, "quality()");
  assert.equal(ip.ratio(), 0.625, "ratio()");

});

////////////////////////////////////////////////////////////////////////////////

QUnit.test("Verify window.devicePixelRatio is pulled in", function(assert) {

	// The other tests force an override to ensure the math works regardless of 
	// the browser being tested. This one just makes sure the data is loaded 
	// normally. 

  
  ///////////
  // Given

  var ip = new ImgTagBuilder({});

  //////////
  // Then

  assert.equal(ip._devicePixelRatio, window.devicePixelRatio, "_devicePixelRatio");

});


////////////////////////////////////////////////////////////////////////////////

QUnit.test("Pick the larger of two config options (in decending order) based on innerWidth", function(assert) {

  //////////
  // Given

  var breakAlpha = { minViewportWidth: 900, maxImageDisplayWidth: 800, quality: 85 };
  var breakBravo = { minViewportWidth: 0, maxImageDisplayWidth: 400, quality: 85 };

  var ip = new ImgTagBuilder({ styles: { main: { breakPoints: [ breakAlpha, breakBravo ] } } });

  //////////
  // When

  ip._devicePixelRatio = 2; // Force to '2' so testing works across devices.
  ip._innerWidth = 1000; // Force for testing regardless of device. 

  ip.prep({ image: "horses.jpg", alt: "some horses",  style: "main", maxWidth: 1600, maxHeight: 1000 });


  //////////
  // Then

  // This is the key requirement. Everything else supports it.
  assert.equal(ip.imgTag(),'<img alt="some horses" class="main" width="800" height="500" src="http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_1600,h_1000/horses.jpg">', "Target `img` tag"); 


});



////////////////////////////////////////////////////////////////////////////////

QUnit.test("Pick the smaller of two config options (in decending order) based on innerWidth", function(assert) {

  //////////
  // Given

  var breakAlpha = { minViewportWidth: 900, maxImageDisplayWidth: 800, quality: 85 };
  var breakBravo = { minViewportWidth: 0, maxImageDisplayWidth: 400, quality: 85 };

  var ip = new ImgTagBuilder({ styles: { main: { breakPoints: [ breakAlpha, breakBravo ] } } });
  

  //////////
  // When

  ip._devicePixelRatio = 2; // Force to '2' so testing works across devices.
  ip._innerWidth = 700; // Force for testing regardless of device. 

  ip.prep({ image: "horses.jpg", alt: "some horses",  style: "main", maxWidth: 1600, maxHeight: 1000 });


  //////////
  // Then

  // This is the key requirement. Everything else supports it.
  assert.equal(ip.imgTag(),'<img alt="some horses" class="main" width="400" height="250" src="http://res.cloudinary.com/demo/image/upload/c_fill,q_85,w_800,h_500/horses.jpg">', "Target `img` tag"); 

});


{'fraction_non_alphanumeric': 0.2376531748978834, 'fraction_numerical': 0.036019309320460456, 'mean_word_length': 2.6544549977385796, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3044455', 'n_tokens_mistral': 2718, 'n_tokens_neox': 2365, 'n_words': 631}