Swap-Aggregator-Subgraph/node_modules/protons/test/strings.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

48 lines
733 B
JavaScript

'use strict'
var tape = require('tape')
var protobuf = require('../src')
var Strings = protobuf(require('./test.proto')).Strings
tape('strings encode + decode', function (t) {
var b1 = Strings.encode({
name: 'hello',
desc: 'world'
})
var o1 = Strings.decode(b1)
t.same(o1, {
name: 'hello',
desc: 'world'
})
t.end()
})
tape('strings encode + decode + omitted', function (t) {
var b1 = Strings.encode({
name: 'hello'
})
var o1 = Strings.decode(b1)
t.same(o1.name, 'hello')
t.notOk(o1.hasDesc())
t.end()
})
tape('strings empty', function (t) {
var b1 = Strings.encode({
name: ''
})
var o1 = Strings.decode(b1)
t.same(o1.name, '')
t.notOk(o1.hasDesc())
t.end()
})