-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transform): always update lazy class declaration
- Loading branch information
1 parent
22f3f23
commit 6dd59b3
Showing
3 changed files
with
67 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as d from '../../../declarations'; | ||
import { transpileModule } from './transpile'; | ||
import { lazyComponentTransform } from '../component-lazy/transform-lazy-component'; | ||
import { mockCompilerCtx } from '@stencil/core/testing'; | ||
|
||
describe('lazy-component', () => { | ||
it('add registerInstance() to constructor w/ decorator on class', () => { | ||
const compilerCtx = mockCompilerCtx(); | ||
const transformOpts: d.TransformOptions = { | ||
coreImportPath: '@stencil/core', | ||
componentExport: 'lazy', | ||
componentMetadata: null, | ||
currentDirectory: '/', | ||
proxy: null, | ||
style: 'static', | ||
}; | ||
|
||
const code = ` | ||
@Component({ | ||
tag: 'cmp-a' | ||
}) | ||
export class CmpA { | ||
@format something = '12'; | ||
} | ||
`; | ||
|
||
const transformer = lazyComponentTransform(compilerCtx, transformOpts); | ||
|
||
const t = transpileModule(code, null, compilerCtx, null, [], [transformer]); | ||
|
||
expect(t.outputText).toContain(`import { registerInstance as __stencil_registerInstance } from "@stencil/core"`); | ||
expect(t.outputText).toContain(`__stencil_registerInstance(this, hostRef)`); | ||
}); | ||
}); |
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