util#TextDecoder JavaScript Examples

The following examples show how to use util#TextDecoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.test.js    From idena-web with MIT License 7 votes vote down vote up
describe('buildDeploymentArgs', () => {
  global.TextEncoder = TextEncoder
  global.TextDecoder = TextDecoder

  describe('winnerThreshold', () => {
    it('should set default winnerThreshold', () => {
      expect(
        buildContractDeploymentArgs({
          title: 'title',
        }).find(({index}) => index === 4)
      ).toHaveProperty('value', '66')
    })

    it('should not replace 0 with default', () => {
      expect(
        buildContractDeploymentArgs({
          title: 'title',
          winnerThreshold: 0,
        }).find(({index}) => index === 4)
      ).toHaveProperty('value', '0')
    })

    it('should respect valid value', () => {
      ;[10, 22, 33, 51, 65, 77, 99].forEach(v =>
        expect(
          buildContractDeploymentArgs({
            title: 'title',
            winnerThreshold: v,
          }).find(({index}) => index === 4)
        ).toHaveProperty('value', String(v))
      )
    })
  })
})
Example #2
Source File: CustomTestEnvironment.js    From lens-extension-cc with MIT License 6 votes vote down vote up
async setup() {
    await super.setup();

    if (!this.global.TextDecoder) {
      this.global.TextDecoder = TextDecoder;
    }

    if (!this.global.TextEncoder) {
      this.global.TextEncoder = TextEncoder;
    }
  }