From 38ad15eded47a28cadae8054ddaeb88202f863a8 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 23 Mar 2024 22:07:49 +0000 Subject: [PATCH] :alembic: Add test to check encoding and then decoding doesn't modify a Colour. --- test/colour.gleam | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/colour.gleam b/test/colour.gleam index fe1d1b6..23cd581 100644 --- a/test/colour.gleam +++ b/test/colour.gleam @@ -1,3 +1,4 @@ +import gleam/json import gleeunit/should import gleam_community/colour @@ -202,3 +203,13 @@ pub fn to_rgb_hex_test() { |> colour.to_rgb_hex() |> should.equal(0xFFAFF3) } + +pub fn json_identiy_test() { + let assert Ok(c) = colour.from_rgba(r: 1.0, g: 1.0, b: 1.0, a: 1.0) + + c + |> colour.encode + |> json.to_string + |> json.decode(colour.decoder) + |> should.equal(Ok(c)) +}