Skip to content

Commit

Permalink
Merge branch '1.x' into release/1.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio authored Jul 17, 2020
2 parents c42b14e + 6862c59 commit 6c2357b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ build using the [web3.js][repo] repository:
npm run build
```

Then include `dist/web3.js` in your html file.
Then include `dist/web3.min.js` in your html file.
This will expose `Web3` on the window object.

Or via jsDelivr CDN:
Expand Down
34 changes: 34 additions & 0 deletions test/utils.isHex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var chai = require('chai');
var utils = require('../packages/web3-utils');

var BigNumber = require('bignumber.js');
var BN = require('bn.js');

var assert = chai.assert;

var tests = [
{ value: 1, expected: true },
{ value: '1', expected: true },
{ value: '0xH', expected: false},
{ value: 'H', expected: false},
{ value: [1,2,3,{test: 'data'}], expected: false},
{ value: {test: 'test'}, expected: false},
{ value: '{"test": "test"}', expected: false},
{ value: 'myString', expected: false},
{ value: 'myString 34534!', expected: false},
{ value: new BN(15), expected: false},
{ value: new BigNumber(15), expected: false},
{ value: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', expected: false},
{ value: true, expected: false},
{ value: false, expected: false}
];

describe('lib/utils/utils', function () {
describe('isHex', function () {
tests.forEach(function (test) {
it('should return ' + test.expected + ' for input ' + test.value, function () {
assert.strictEqual(utils.isHex(test.value), test.expected);
});
});
});
});
34 changes: 34 additions & 0 deletions test/utils.isHexStrict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var chai = require('chai');
var utils = require('../packages/web3-utils');

var BigNumber = require('bignumber.js');
var BN = require('bn.js');

var assert = chai.assert;

var tests = [
{ value: 0x1, expected: false }, //0x1 would be tested as 1
{ value: '0x1', expected: true },
{ value: '0xH', expected: false},
{ value: 'H', expected: false},
{ value: [1,2,3,{test: 'data'}], expected: false},
{ value: {test: 'test'}, expected: false},
{ value: '{"test": "test"}', expected: false},
{ value: 'myString', expected: false},
{ value: 'myString 34534!', expected: false},
{ value: new BN(15), expected: false},
{ value: new BigNumber(15), expected: false},
{ value: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', expected: false},
{ value: true, expected: false},
{ value: false, expected: false}
];

describe('lib/utils/utils', function () {
describe('isHexStrict', function () {
tests.forEach(function (test) {
it('should return ' + test.expected + ' for input ' + test.value, function () {
assert.strictEqual(utils.isHexStrict(test.value), test.expected);
});
});
});
});

0 comments on commit 6c2357b

Please sign in to comment.