/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/fast-json-stringify/test/bigint.test.js
76 строк
1 KB
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
'use strict' const { test } = require('node:test') const build = require('..') test('render a bigint as JSON', (t) => { t.plan(1) const schema = { title: 'bigint', type: 'integer' } const stringify = build(schema) const output = stringify(1615n) t.assert.equal(output, '1615') }) test('render an object with a bigint as JSON', (t) => { t.plan(1) const schema = { title: 'object with bigint', type: 'object', properties: { id: { type: 'integer' } } } const stringify = build(schema) const output = stringify({ id: 1615n }) t.assert.equal(output, '{"id":1615}') }) test('render an array with a bigint as JSON', (t) => { t.plan(1) const schema = { title: 'array with bigint', type: 'array', items: { type: 'integer' } } const stringify = build(schema) const output = stringify([1615n]) t.assert.equal(output, '[1615]') }) test('render an object with an additionalProperty of type bigint as JSON', (t) => { t.plan(1) const schema = { title: 'object with bigint', type: 'object', additionalProperties: { type: 'integer' } } const stringify = build(schema) const output = stringify({ num: 1615n }) t.assert.equal(output, '{"num":1615}') })