1.0.0 • Published 6 years ago

hex-to-rgb-jquery v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

hex-to-rgb-jquery

Unit testing helper function that converts hex colors to rgb colors

license npm Travis 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 Thomas Lindner. Licensed under the MIT license.