Base64.test.js 1021 B

1234567891011121314151617181920212223242526272829
  1. const { expect } = require('chai');
  2. const Base64Mock = artifacts.require('Base64Mock');
  3. contract('Strings', function () {
  4. beforeEach(async function () {
  5. this.base64 = await Base64Mock.new();
  6. });
  7. describe('from bytes - base64', function () {
  8. it('converts to base64 encoded string with double padding', async function () {
  9. const TEST_MESSAGE = 'test';
  10. const input = web3.utils.asciiToHex(TEST_MESSAGE);
  11. expect(await this.base64.encode(input)).to.equal('dGVzdA==');
  12. });
  13. it('converts to base64 encoded string with single padding', async function () {
  14. const TEST_MESSAGE = 'test1';
  15. const input = web3.utils.asciiToHex(TEST_MESSAGE);
  16. expect(await this.base64.encode(input)).to.equal('dGVzdDE=');
  17. });
  18. it('converts to base64 encoded string without padding', async function () {
  19. const TEST_MESSAGE = 'test12';
  20. const input = web3.utils.asciiToHex(TEST_MESSAGE);
  21. expect(await this.base64.encode(input)).to.equal('dGVzdDEy');
  22. });
  23. });
  24. });