পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Thursday, February 23, 2017

JasmineJS - Boolean Check

Apart from equality check, Jasmine provides some methods to check Boolean conditions too. Following are the methods that help us check Boolean conditions.

toBeTruthy()

This Boolean matcher is used in Jasmine to check whether the result is equal to true or false.
The following example will help us understand the working principle of the toBeTruthy() function.

ExpectSpec.js

describe("Different Methods of Expect Block",function (){  

   it("The Example of toBeTruthy() method",function (){   
      expect(expectexam.exampleoftrueFalse(5)).toBeTruthy();    
   });  

}); 

Expectexam.js

window.expectexam = {  

   exampleoftrueFalse: function (num){  
      if(num < 10)    
         return true;  
      else   
         return false;  
   },  

};
As we are passing number 5, which is smaller than 10, this test case will pass and give us the following output.
toBeTruthy Method If we pass a number which is larger than 10, then this green test will change to red. In the second screenshot, you can see that on passing some value which is greater than 10, the expected test case fails and generates red output stating that “Expected false to be truthy”.
toBeTruthy Error

toBeFalsy()

toBeFalsy() also works the same way as toBeTruthy() method. It matches the output to be false whereas toBeTruthy matches the output to be true. The following example will help you understand the basic working principles of toBeFalsy().

ExpectSpec.js

describe("Different Methods of Expect Block",function(){ 

   it("The Example of toBeTruthy() method",function (){
      expect(expectexam.exampleoftrueFalse(15)).toBeFalsy();   
   }); 

});

Expectexam.js

window.expectexam = {  
   
   exampleoftrueFalse: function (num){  
      if(num < 10)    
         Return true;  
      else   
         return false; 
   }, 

}; 
The above code will pass the Jasmine test case as we are passing value more than 10 and expected the output to be false. Hence, the browser will show us a green sign which means it has passed.
toBeTruthy Method

No comments:

Post a Comment