Skip to content

Commit

Permalink
test: check when previous post matches the current song name
Browse files Browse the repository at this point in the history
[#1]
  • Loading branch information
alxndr committed Nov 21, 2024
1 parent ca6fbaf commit 313cda6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,34 @@ describe('handlePayload', () => {
})
})
})
describe('with valid login and prior post _does_ match latest song title', () => {
const mockedLoginReturnValue = {
getAuthorFeed: vi.fn().mockReturnValueOnce({data: {feed: [{post: {record: {text: 'Song Title'}}}] }}),
}
beforeEach(() => {
vi.mocked(login).mockResolvedValue(mockedLoginReturnValue)
})
afterEach(() => {
vi.mocked(login).mockReset()
})
describe(`when payload's show_id matches fetched JSON's data[-1].show_id`, () => {
let mockedPost
beforeEach(() => {
mockedPost = vi.fn().mockReturnValueOnce({mocked: true})
vi.mocked(login).mockResolvedValue({
...mockedLoginReturnValue,
post: mockedPost,
})
mockJson(/\bkglw\.net\b.+\blatest\.json$/, {data: [
{show_id: 123, songname: 'Song Title'},
]})
})
test('does _not_ post the song title', async () => {
await handlePayload(payload)
expect(mockedPost).not.toHaveBeenCalled()
})
})
})
})
describe('with fixture payload matching latest show_id', () => {
const testWithFixture = test.extend({
Expand Down

0 comments on commit 313cda6

Please sign in to comment.