Last active
December 15, 2024 12:06
-
-
Save YonatanKra/cb2379913a10ac6823481161968b1f70 to your computer and use it in GitHub Desktop.
First test for our AltTextBot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AltTextBot } from './find-altless-posts.js'; | |
let mockAtpAgent; | |
const resetAtpAgentMock = () => { | |
mockAtpAgent = { | |
getPost: vi.fn(), | |
}; | |
} | |
vi.mock('@atproto/api', () => ({ | |
AtpAgent: vi.fn(() => mockAtpAgent), | |
})); | |
describe('AltTextBot', () => { | |
const postUri = 'postUri'; | |
let bot: AltTextBot; | |
beforeEach(async () => { | |
resetAtpAgentMock(); | |
bot = new AltTextBot(); | |
}); | |
it('should initialize a new instance', async () => { | |
expect(bot).toBeDefined(); | |
}); | |
describe('checkAltInSinglePost()', () => { | |
it('should return the error message if fetch post failed', async () => { | |
const error = { message: 'error' }; | |
mockAtpAgent.getPost.mockRejectedValue(error); | |
const result = await bot.checkSinglePost(postUri); | |
expect(result).toEqual(error); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment