mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-26 21:01:14 +08:00
32 lines
625 B
Go
32 lines
625 B
Go
// SPDX-FileCopyrightText: 2023-2025 Steffen Vogel <post@steffenvogel.de>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package tty_test
|
|
|
|
import (
|
|
"cunicu.li/cunicu/pkg/tty"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Context("re-indent json", func() {
|
|
It("works", func() {
|
|
original := []byte(`{ "a": { "b": { "c": 5 } } }`)
|
|
indented := []byte(`{
|
|
"a": {
|
|
"b": {
|
|
"c": 5
|
|
}
|
|
}
|
|
}`)
|
|
|
|
Expect(tty.ReIndentJSON(original, "", " ")).To(Equal(indented))
|
|
})
|
|
|
|
It("fails for invalid json", func() {
|
|
_, err := tty.ReIndentJSON([]byte("{"), "", " ")
|
|
Expect(err).To(HaveOccurred())
|
|
})
|
|
})
|