-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): fix app env flag regression (close #1612)
- Loading branch information
Showing
5 changed files
with
66 additions
and
6 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
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,29 @@ | ||
import { expect, it } from 'vitest' | ||
import type { App, BuildApp, Bundler } from '../../src/index.js' | ||
import { createBuildApp } from '../../src/index.js' | ||
|
||
it('should create build app correctly', () => { | ||
const checkApp = (app: App): void => { | ||
expect(app.env.isDev).toBe(false) | ||
expect((app as unknown as { dev: never }).dev).toBeUndefined() | ||
|
||
expect(app.env.isBuild).toBe(true) | ||
expect(typeof (app as BuildApp).build).toBe('function') | ||
} | ||
|
||
const buildApp = createBuildApp({ | ||
source: '/foo', | ||
theme: (appInTheme) => { | ||
checkApp(appInTheme) | ||
return { name: 'test-theme' } | ||
}, | ||
bundler: {} as Bundler, | ||
plugins: [ | ||
(appInPlugin) => { | ||
checkApp(appInPlugin) | ||
return { name: 'test-plugin' } | ||
}, | ||
], | ||
}) | ||
checkApp(buildApp) | ||
}) |
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,29 @@ | ||
import { expect, it } from 'vitest' | ||
import type { App, Bundler, DevApp } from '../../src/index.js' | ||
import { createDevApp } from '../../src/index.js' | ||
|
||
it('should create dev app correctly', () => { | ||
const checkApp = (app: App): void => { | ||
expect(app.env.isDev).toBe(true) | ||
expect(typeof (app as DevApp).dev).toBe('function') | ||
|
||
expect(app.env.isBuild).toBe(false) | ||
expect((app as unknown as { build: never }).build).toBeUndefined() | ||
} | ||
|
||
const devApp = createDevApp({ | ||
source: '/foo', | ||
theme: (appInTheme) => { | ||
checkApp(appInTheme) | ||
return { name: 'test-theme' } | ||
}, | ||
bundler: {} as Bundler, | ||
plugins: [ | ||
(appInPlugin) => { | ||
checkApp(appInPlugin) | ||
return { name: 'test-plugin' } | ||
}, | ||
], | ||
}) | ||
checkApp(devApp) | ||
}) |