GithubHelp home page GithubHelp logo

tclindner / hex-to-rgb-jquery Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 66 KB

Unit testing helper function that converts hex colors to rgb colors

License: MIT License

JavaScript 100.00%
testing-tools hex rgb jquery

hex-to-rgb-jquery's Introduction

hex-to-rgb-jquery

Unit testing helper function that converts hex colors to rgb colors

license npm ci Dependency Status devDependency Status

What is hex-to-rgb-jquery?

hex-to-rgb-jquery is a wrapper for onecolor that adjusts its response, so it matches the rgb format jQuery returns.

Install

$ npm install hex-to-rgb-jquery --save-dev

Usage

Add the following script tag to your unit test runner.

<script src="../node_modules/hex-to-rgb-jquery/dist/hex-to-rgb.js"></script>

Example

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test Runner</title>
    <link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
    <!-- lib scripts -->
    <script src="../node_modules/mocha/mocha.js"></script>
    <script src="../node_modules/chai/chai.js"></script>

    <!-- hex-to-rgb script -->
    <script src="../node_modules/hex-to-rgb-jquery/dist/hex-to-rgb.js"></script>

    <!-- Mocha setup -->
    <script type="text/javascript">
      chai.should();
      mocha.setup('bdd');
      // Start the suite.
      window.onload = function() {
        mocha.run();
      };
    </script>
  </head>
  <body>
    <div id="mocha"></div>
    <div id="fixture"></div>

    <!-- source code scripts -->

    <!-- test scripts -->
  </body>
</html>

Call the function in the test

window.hexToRgbJquery.hexToRgb('#fff');

Ex in context of a test:

var hexToRgb = window.hexToRgbJquery.hexToRgb;

describe('hex-to-rgb tests', function() {
  context('when a hex value is passed', function() {
    it('with all six characters a valid corresponding rgb value should be returned', function() {
      hexToRgb('#f1f1f1').should.equal('rgb(241, 241, 241)');
    });
  });
});

Contributing

Please see CONTRIBUTING.md.

Release History

Please see CHANGELOG.md.

License

Copyright (c) 2017-2020 Thomas Lindner. Licensed under the MIT license.

hex-to-rgb-jquery's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar tclindner avatar

Watchers

 avatar  avatar

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.