-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add reporting for shadowSupportMode (#3980)
* feat: add reporting for shadowSupportMode
- Loading branch information
Showing
7 changed files
with
105 additions
and
1 deletion.
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
66 changes: 66 additions & 0 deletions
66
...es/@lwc/integration-karma/test/mixed-shadow-mode/shadowSupportModeReporting/index.spec.js
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,66 @@ | ||
import { createElement } from 'lwc'; | ||
import { attachReportingControlDispatcher, detachReportingControlDispatcher } from 'test-utils'; | ||
|
||
import Any from 'x/any'; | ||
import Reset from 'x/reset'; | ||
import None from 'x/none'; | ||
import NativeOnly from 'x/native'; | ||
|
||
// Should be kept in sync with the enum in vm.ts | ||
const ShadowSupportMode = { | ||
Any: 'any', | ||
Default: 'reset', | ||
Native: 'native', | ||
}; | ||
|
||
/** | ||
* These tests must be the first ones to generate the component def for the components they use. | ||
* This is because subsequent calls to create the component will use the cached ctor rather than | ||
* recreating the entire def. We only report on that initial def creation for perf reasons. | ||
*/ | ||
describe('shadow support mode reporting', () => { | ||
let dispatcher; | ||
|
||
beforeEach(() => { | ||
dispatcher = jasmine.createSpy(); | ||
attachReportingControlDispatcher(dispatcher, ['ShadowSupportModeUsage']); | ||
}); | ||
|
||
afterEach(() => { | ||
detachReportingControlDispatcher(); | ||
}); | ||
|
||
it('should report use of value "any"', () => { | ||
expect(() => { | ||
createElement('x-any', { is: Any }); | ||
}).toLogWarningDev(/Invalid value 'any' for static property shadowSupportMode/); | ||
|
||
expect(dispatcher).toHaveBeenCalledTimes(1); | ||
expect(dispatcher).toHaveBeenCalledWith('ShadowSupportModeUsage', { | ||
tagName: Any.name, | ||
mode: ShadowSupportMode.Any, | ||
}); | ||
}); | ||
|
||
it('should report use of value "native"', () => { | ||
createElement('x-native', { is: NativeOnly }); | ||
|
||
expect(dispatcher).toHaveBeenCalledTimes(1); | ||
expect(dispatcher).toHaveBeenCalledWith('ShadowSupportModeUsage', { | ||
tagName: NativeOnly.name, | ||
mode: ShadowSupportMode.Native, | ||
}); | ||
}); | ||
|
||
it('should not report use of value "reset"', () => { | ||
createElement('x-reset', { is: Reset }); | ||
|
||
expect(dispatcher).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
it('should not report when no value is provided', () => { | ||
createElement('x-none', { is: None }); | ||
|
||
expect(dispatcher).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
...ges/@lwc/integration-karma/test/mixed-shadow-mode/shadowSupportModeReporting/x/any/any.js
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,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Any extends LightningElement { | ||
static shadowSupportMode = 'any'; | ||
} |
5 changes: 5 additions & 0 deletions
5
...wc/integration-karma/test/mixed-shadow-mode/shadowSupportModeReporting/x/native/native.js
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,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Native extends LightningElement { | ||
static shadowSupportMode = 'native'; | ||
} |
3 changes: 3 additions & 0 deletions
3
...s/@lwc/integration-karma/test/mixed-shadow-mode/shadowSupportModeReporting/x/none/none.js
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,3 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class None extends LightningElement {} |
5 changes: 5 additions & 0 deletions
5
...@lwc/integration-karma/test/mixed-shadow-mode/shadowSupportModeReporting/x/reset/reset.js
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,5 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Reset extends LightningElement { | ||
static shadowSupportMode = 'reset'; | ||
} |