-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce vitest and first homepage tests (#45)
- Loading branch information
Showing
5 changed files
with
883 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
packages/core/installMachine/installSteps/homepage/__tests__/install.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { homepageFiles } from '../../../../templates/homepage/installConfig'; | ||
import { templateGenerator } from '../../../../utils/generator/generator'; | ||
import { getTemplateDirectory } from '../../../../utils/getTemplateDirectory'; | ||
import { modifyHomepage } from '../install'; | ||
|
||
// Mock dependencies | ||
vi.mock('../../../../utils/generator/generator'); | ||
vi.mock('../../../../utils/getTemplateDirectory'); | ||
vi.mock('../../../../utils/logger', () => ({ | ||
logger: { | ||
withSpinner: vi.fn((_, __, callback) => callback({ succeed: vi.fn(), fail: vi.fn() })), | ||
}, | ||
})); | ||
|
||
describe('modifyHomepage', () => { | ||
it('should correctly set up homepage files', async () => { | ||
// Arrange | ||
const destinationDirectory = '/mock/destination'; | ||
const mockTemplateDirectory = '/mock/template/directory'; | ||
|
||
// Mock getTemplateDirectory to return a specific path | ||
vi.mocked(getTemplateDirectory).mockReturnValue(mockTemplateDirectory); | ||
|
||
// Act | ||
await modifyHomepage(destinationDirectory); | ||
|
||
// Assert | ||
expect(getTemplateDirectory).toHaveBeenCalledWith('/templates/homepage/files/'); | ||
expect(templateGenerator).toHaveBeenCalledWith(homepageFiles, mockTemplateDirectory, destinationDirectory); | ||
}); | ||
}); |
Oops, something went wrong.