more tests
This commit is contained in:
@@ -4,6 +4,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from "vitest"
|
||||
import {follow, mute, pin, unfollow, unmute, unpin} from "../src/commands"
|
||||
import * as thunkModule from "../src/thunk"
|
||||
import {thunkWorker} from "../src/thunk"
|
||||
import {repository} from "../src/core"
|
||||
|
||||
vi.mock(import("@welshman/lib"), async importOriginal => ({
|
||||
...(await importOriginal()),
|
||||
@@ -48,6 +49,8 @@ describe("commands", () => {
|
||||
vi.resetModules()
|
||||
// Clear any cached data
|
||||
vi.clearAllMocks()
|
||||
|
||||
repository.load([])
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -64,6 +67,7 @@ describe("commands", () => {
|
||||
it("should create new follows list if none exists", async () => {
|
||||
const publishThunkSpy = vi.spyOn(thunkModule, "publishThunk")
|
||||
await follow(["p", pubkey1])
|
||||
await vi.runAllTimersAsync()
|
||||
|
||||
expect(publishThunkSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -85,6 +89,8 @@ describe("commands", () => {
|
||||
|
||||
await follow(["p", pubkey2])
|
||||
|
||||
await vi.runAllTimersAsync()
|
||||
|
||||
expect(publishThunkSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
event: expect.objectContaining({
|
||||
@@ -126,6 +132,8 @@ describe("commands", () => {
|
||||
|
||||
await mute(["p", pubkey1])
|
||||
|
||||
await vi.runAllTimersAsync()
|
||||
|
||||
expect(publishThunkSpy).toHaveBeenCalledWith({
|
||||
event: expect.objectContaining({
|
||||
kind: MUTES,
|
||||
@@ -144,6 +152,8 @@ describe("commands", () => {
|
||||
|
||||
await mute(["p", pubkey2])
|
||||
|
||||
await vi.runAllTimersAsync()
|
||||
|
||||
expect(publishThunkSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
event: expect.objectContaining({
|
||||
@@ -184,6 +194,8 @@ describe("commands", () => {
|
||||
const publishThunkSpy = vi.spyOn(thunkModule, "publishThunk")
|
||||
await pin(["e", event1])
|
||||
|
||||
await vi.runAllTimersAsync()
|
||||
|
||||
expect(publishThunkSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
event: expect.objectContaining({
|
||||
@@ -204,6 +216,8 @@ describe("commands", () => {
|
||||
|
||||
await pin(["e", event2])
|
||||
|
||||
await vi.runAllTimersAsync()
|
||||
|
||||
expect(publishThunkSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
event: expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user