freeCodeCamp / curriculum

The freeCodeCamp curriculum and lesson editor
Creative Commons Attribution Share Alike 4.0 International
81 stars 124 forks source link

Give a Background Color to a Div Element - missing test allows challenge to pass without creating silver-background class to change background of div to silver per instructions #254

Closed RandellDawson closed 6 years ago

RandellDawson commented 6 years ago

Describe your problem and - if possible - how to reproduce it

Part of this challenge states:

Create a class called silver-background with the background-color of silver.

There is currently not a test which validates a class name of silver-background is defined which specifies the background-color property's value to be silver. The current tests only check: 1) That the existing div element's class attribute value is "silver-background". 2) That the final background color of the div element is silver.

Because it does not validate the class name of silver-background is define correctly, the following code will pass the test. I commented the line in the style section below which allows user to pass challenge incorrectly

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, monospace;
  }

  p {
    font-size: 16px;
    font-family: monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }

  div { /* This should not pass the tests */
    background-color: silver;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>
<main>
  <p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>

  <div class="silver-background">
    <p>Things cats love:</p>
    <ul>
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
    <p>Top 3 things cats hate:</p>
    <ol>
      <li>flea treatment</li>
      <li>thunder</li>
      <li>other cats</li>
    </ol>
  </div>

  <form action="/submit-cat-photo">
    <label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
    <label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
    <label><input type="checkbox" name="personality" checked> Loving</label>
    <label><input type="checkbox" name="personality"> Lazy</label>
    <label><input type="checkbox" name="personality"> Energetic</label><br>
    <input type="text" placeholder="cat photo URL" required>
    <button type="submit">Submit</button>
  </form>
</main>

Partial Solution: I have not worked enough with test program to know how to best write the actual regex expression to make this check, but I have created the framework for the needed 3rd test below:

{
    text: "Define a class named <code>silver-background</code> within the <code>style</code> element and assign the value of <code>silver</code> to the <code>background-color</code> property.",
    testString: 'assert(Some Regex Expression to go here), \'Define a class named <code>silver-background</code> within the <code>style</code> element and assign the value of <code>silver</code> to the <code>background-color</code> property.\');'
}

Add a Link to the page with the problem

https://learn.freecodecamp.org/responsive-web-design/basic-css/give-a-background-color-to-a-div-element/

Tell us about your browser and operating system

If possible, add a screenshot here

image

Nirajn2311 commented 6 years ago

I’ll work on it.

raisedadead commented 5 years ago

:tada: This issue has been resolved in version 3.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: