Skip to content

Commit

Permalink
chore: improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Feb 15, 2025
1 parent 2536e04 commit 4793e81
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/bunfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,16 @@ describe('bunfig', () => {

describe('generateConfigTypes', () => {
it('should generate config types', () => {
// Create some test config files
writeFileSync(resolve(testConfigDir, 'app.ts'), 'export default {}')
writeFileSync(resolve(testConfigDir, 'test.ts'), 'export default {}')
// Create test config files in alphabetical order
const configFiles = [
['app.ts', 'export default {}'],
['test.ts', 'export default {}'],
]

// Create files in sorted order
configFiles.sort((a, b) => a[0].localeCompare(b[0])).forEach(([filename, content]) => {
writeFileSync(resolve(testConfigDir, filename), content)
})

generateConfigTypes({
configDir: testConfigDir,
Expand All @@ -328,7 +335,8 @@ describe('bunfig', () => {
expect(existsSync(typesFile)).toBe(true)

const content = readFileSync(typesFile, 'utf-8')
expect(content).toContain('export type ConfigNames = \'app\' | \'test\'')
// Check for exact string since we now control the order
expect(content).toBe('// Generated by bunfig\nexport type ConfigNames = \'app\' | \'test\'\n')

Check failure on line 339 in test/bunfig.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: "// Generated by bunfig\nexport type ConfigNames = 'app' | 'test'\n" Received: "// Generated by bunfig\nexport type ConfigNames = 'test' | 'app'\n" at <anonymous> (/home/runner/work/bunfig/bunfig/test/bunfig.test.ts:339:23)
})

it('should handle empty config directory', () => {
Expand Down

0 comments on commit 4793e81

Please sign in to comment.