Giter Club home page Giter Club logo

sassmine's Introduction

Sassmine

Sassmine is a collection of mixins available for you to create unit tests in Sass. Inspired by Jasmine for JavaScript unit testing, Sassmine makes use of similiar naming for it's mixins as Jasmine does for it's functions.

At the moment Sassmine compiles test results to a CSS file. The test results will, in the not so distant future, be output and formatted to the console.

Setup

Pull down the repo and install node packages via npm install:

npm install

Then run gulp:

gulp

Gulp will run the default task which runs a Sass task to build the example.css, it also concats the Sassmine utility into a single file in the build folder for you to include in your projects:

@import "pathToSassmine/sassmine";

Mixins

Statements

  • describe($name)
  • xdescribe($name)
  • it($label)
  • xit($label)

Asserts

  • toBeLesser($actual, $expected)
  • toBeGreater($actual, $expected)
  • toEqual($actual, $expected)
  • toNotEqual($actual, $expected)
  • toBeCloseTo($actual, $expected, $precision)
  • toBeDefined($value)
  • toBeUndefined($value)
  • toBeNull($value)
  • toNotBeNull($value)
  • toBeColor($value)
  • toBeNaN($value)
  • toContain($string, $subString)

Example

Sassmine offers a friendly syntax most similar to Jasmine for JavaScript. Sassmine asserts are slightly different and have been compacted into slight variants of the known JS equivalents.

$var: 10;

@mixin size($width, $height) {
  height: $height;
  width: $width;
}

@include describe("Test Module") {
  @include it("should be defined") {
    @include toBeDefined(var);  
    @include toBeDefined(vaerwr);
  }
  
  @include it("should not be defined") {
    @include toBeUndefined(size);
    @include toBeUndefined(abs);
    @include toBeUndefined($var);
  }
  
  @include it("should equal") {
    @include toEqual(20, 20);
    @include toEqual(yellow, blue);
  }
  
  @include it("should not equal") {
    @include toNotEqual(20, 20);
    @include toNotEqual(#eee, #ccc);
    @include toNotEqual(yellow, blue);
  }
  
  @include it("should be greater") {
    @include toBeGreater(5, 6);
    @include toBeGreater(20, 600);
  }
  
  @include it("should be lesser") {
    @include toBeLesser(5, 6);
    @include toBeLesser(1000, 50);
  }
  
  @include it("should not be a number") {
    @include toBeNaN(string);
    @include toBeNaN(10);
  }
  
  @include it("should be a color") {
    @include toBeColor(red);  
    @include toBeColor(rgba(0, 0, 0, 0.5));  
    @include toBeColor(#000);
    @include toBeColor(name);
  }
  
  @include it("should be null") {
    @include toBeNull(null);
    @include toBeNull(#333);
  }
  
  @include it("should not be null") {
    @include toNotBeNull(null);
    @include toNotBeNull(#333);
  }
  
  @include it("should be close to") {
    @include toBeCloseTo(3, 5);
    @include toBeCloseTo(3, 5, 1);
  }
  
  @include it("should contain") {
    @include toContain('http://www.google.com', 'http');
    @include toContain('http://www.facebook.com', 'https');
  }
}

sassmine's People

Contributors

brendoncon avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

sassmine's Issues

Add extra asserts

A few extra asserts would be useful for this feature:

toBeGreaterThanOrEqual
toBeLesserThanOrEqual
toContain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.