-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp: Went half way through the test for the entry file
- Loading branch information
1 parent
9abf2ce
commit 7d6968b
Showing
2 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { readFileSync } from 'fs'; | ||
import { describe, test, expect, beforeAll, beforeEach, vi } from 'vitest'; | ||
import { convertToSelectorUtil } from '../convert-to-selectors'; | ||
import { generateTestUtils } from '../generate-test-utils'; | ||
import { ComponentMetadata } from '../interfaces'; | ||
|
||
vi.mock('fs'); | ||
vi.mock('../convert-to-selectors'); | ||
|
||
const mockComponents: ComponentMetadata[] = [ | ||
{ | ||
name: 'Alert', | ||
pluralName: 'Alerts', | ||
testUtilsFolderName: '../test-utils', | ||
}, | ||
{ | ||
name: 'Status', | ||
pluralName: 'Status', // The plural name is deliberately the same as singular | ||
testUtilsFolderName: '../test-utils', | ||
}, | ||
]; | ||
|
||
describe(`${generateTestUtils.name}`, () => { | ||
beforeAll(() => { | ||
vi.mocked(readFileSync).mockReturnValue('file content'); | ||
vi.mocked(convertToSelectorUtil).mockImplementation(input => input); | ||
}); | ||
|
||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
test('generates the selector utils for the given dom utils', () => { | ||
generateTestUtils({ | ||
components: mockComponents, | ||
testUtilsPath: './test/mock-test-utils', | ||
}); | ||
|
||
expect(readFileSync).toHaveBeenCalledWith('mock-test-utils/dom'); | ||
}); | ||
}); |