]> git.r.bdr.sh - rbdr/forum/blobdiff - src/lib/stores/actions.test.ts
Update / use typescript
[rbdr/forum] / src / lib / stores / actions.test.ts
diff --git a/src/lib/stores/actions.test.ts b/src/lib/stores/actions.test.ts
new file mode 100644 (file)
index 0000000..c650536
--- /dev/null
@@ -0,0 +1,32 @@
+import { enableTopicActions, disableTopicActions, topicActions } from './actions';
+
+describe('Topic actions and state', () => {
+
+  test('There should be no topic actions by default', () => {
+
+    topicActions.subscribe((actions) => {
+
+      expect(actions).toBe(undefined);
+    })();
+  });
+
+  test('enableTopicActions should set the topic id', () => {
+
+    enableTopicActions('free_hat');
+    topicActions.subscribe((actions) => {
+
+      expect(actions).toEqual({
+        id: 'free_hat'
+      });
+    })();
+  });
+
+  test('disableTopicActions should unset the topic id', () => {
+
+    disableTopicActions();
+    topicActions.subscribe((actions) => {
+
+      expect(actions).toEqual(undefined);
+    })();
+  });
+});