Skip to content

Commit 65700ab

Browse files
committed
test: add a couple of tests
1 parent 698fe18 commit 65700ab

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,43 @@ describe('onBuild()', () => {
559559
})
560560

561561
describe('onPostBuild', () => {
562+
const { isOldPluginInstalled } = require('../packages/runtime/src/helpers/utils')
563+
564+
test('show warning message to remove old plugin', async () => {
565+
isOldPluginInstalled.mockImplementation(() => {
566+
return true
567+
})
568+
const mockStatusFunc = jest.fn()
569+
570+
await plugin.onPostBuild({
571+
...defaultArgs,
572+
utils: { ...utils, status: { show: mockStatusFunc } }
573+
})
574+
575+
expect(mockStatusFunc).toHaveBeenCalledWith({ "summary": "Please remove @netlify/plugin-nextjs from your site. It is no longer required and will prevent you using new features." })
576+
577+
})
578+
579+
test('does not show warning message to remove old plugin', async () => {
580+
isOldPluginInstalled.mockImplementation(() => {
581+
return false
582+
})
583+
const mockStatusFunc = jest.fn()
584+
await moveNextDist()
585+
586+
await plugin.onPostBuild({
587+
...defaultArgs,
588+
utils: {
589+
...utils,
590+
status: { show: mockStatusFunc },
591+
functions: { list: jest.fn().mockResolvedValue([]) }
592+
}
593+
})
594+
595+
expect(mockStatusFunc).not.toHaveBeenCalledWith({ "summary": "Please remove @netlify/plugin-nextjs from your site. It is no longer required and will prevent you using new features." })
596+
597+
})
598+
562599
test('saves cache with right paths', async () => {
563600
await moveNextDist()
564601

0 commit comments

Comments
 (0)