From 04444789524d861c3bdc7ac36f13df72c01c0bc8 Mon Sep 17 00:00:00 2001
From: Jono Wenger <jono@elixxir.io>
Date: Mon, 24 Oct 2022 14:21:24 -0700
Subject: [PATCH] Add tests for StoreIndexedDbEncryptionStatus

---
 storage/indexedDbEncryptionTrack_test.go | 40 ++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 storage/indexedDbEncryptionTrack_test.go

diff --git a/storage/indexedDbEncryptionTrack_test.go b/storage/indexedDbEncryptionTrack_test.go
new file mode 100644
index 00000000..ec754f87
--- /dev/null
+++ b/storage/indexedDbEncryptionTrack_test.go
@@ -0,0 +1,40 @@
+////////////////////////////////////////////////////////////////////////////////
+// Copyright © 2022 xx foundation                                             //
+//                                                                            //
+// Use of this source code is governed by a license that can be found in the  //
+// LICENSE file.                                                              //
+////////////////////////////////////////////////////////////////////////////////
+
+//go:build js && wasm
+
+package storage
+
+import (
+	"testing"
+)
+
+// Tests that StoreIndexedDbEncryptionStatus stores the initial encryption value
+// and return that value on subsequent checks.
+func TestStoreIndexedDbEncryptionStatus(t *testing.T) {
+	databaseName := "databaseA"
+
+	encrypted, err := StoreIndexedDbEncryptionStatus(databaseName, true)
+	if err != nil {
+		t.Errorf("Failed to store/get encryption status: %+v", err)
+	}
+
+	if encrypted != true {
+		t.Errorf("Incorrect encryption values.\nexpected: %t\nreceived: %t",
+			true, encrypted)
+	}
+
+	encrypted, err = StoreIndexedDbEncryptionStatus(databaseName, false)
+	if err != nil {
+		t.Errorf("Failed to store/get encryption status: %+v", err)
+	}
+
+	if encrypted != true {
+		t.Errorf("Incorrect encryption values.\nexpected: %t\nreceived: %t",
+			true, encrypted)
+	}
+}
-- 
GitLab