-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Migrate jest to use projects feature #322
Changes from 9 commits
79acc55
e71b82a
b2cf0d9
704ee1d
bd1ec47
a46695a
c9f2af7
803109b
7e7d3ac
e046412
1a6d11a
b0d9377
52da269
2839cdc
b222796
385e839
32c340e
bfe25cf
064ca91
3a1b277
ba09e2a
d0d3242
a9921a2
56d1a1b
7c31f72
c90ef6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const BASE_CONFIG = require('../../scripts/jest/base.config'); | ||
|
||
module.exports = { | ||
...BASE_CONFIG, | ||
displayName: 'babel-plugin-transform-lwc-class', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const BASE_CONFIG = require('../../scripts/jest/base.config'); | ||
|
||
module.exports = { | ||
...BASE_CONFIG, | ||
displayName: 'lwc-compiler', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const BASE_CONFIG = require('../../scripts/jest/base.config'); | ||
|
||
module.exports = { | ||
...BASE_CONFIG, | ||
displayName: 'lwc-engine', | ||
setupTestFrameworkScriptFile: '<rootDir>/scripts/jest/setup.ts', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { flushComponentRegistry } from '../../src/framework/def'; | ||
|
||
// Clean-up after each test the engine component registry. This avoid having the | ||
// engine warning that multiple component class are registered with the same name. | ||
afterEach(() => { | ||
flushComponentRegistry(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,27 +7,28 @@ import { VNode } from "../../3rdparty/snabbdom/types"; | |
import { Component } from "../component"; | ||
import { unwrap } from "../main"; | ||
import { querySelector } from "../dom"; | ||
import { callbackify } from "util"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hate when we have util package, it messes up with our regular autoimports if they match the same exported name :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch. I will remove this, it was inserted by VSCode! |
||
|
||
describe('html-element', () => { | ||
describe('#setAttributeNS()', () => { | ||
it('should set attribute on host element when element is nested in template', () => { | ||
class MyComponent extends Element { | ||
class Child extends Element { | ||
setFoo() { | ||
this.setAttributeNS('x', 'foo', 'bar'); | ||
} | ||
} | ||
MyComponent.publicMethods = ['setFoo']; | ||
Child.publicMethods = ['setFoo']; | ||
|
||
class Parent extends Element { | ||
render() { | ||
return ($api) => { | ||
return [$api.c('should-set-attribute-on-host-element-when-element-is-nested-in-template-child', MyComponent, {})] | ||
return [$api.c('x-child', Child, {})] | ||
} | ||
} | ||
} | ||
const element = createElement('should-set-attribute-on-host-element-when-element-is-nested-in-template', { is: Parent }); | ||
document.body.appendChild(element); | ||
const child = querySelector.call(element, 'should-set-attribute-on-host-element-when-element-is-nested-in-template-child'); | ||
const child = querySelector.call(element, 'x-child'); | ||
child.setFoo(); | ||
expect(child.hasAttributeNS('x', 'foo')).toBe(true); | ||
expect(child.getAttributeNS('x', 'foo')).toBe('bar'); | ||
|
@@ -61,23 +62,23 @@ describe('html-element', () => { | |
|
||
describe('#setAttribute()', () => { | ||
it('should set attribute on host element when element is nested in template', () => { | ||
class MyComponent extends Element { | ||
class Child extends Element { | ||
setFoo() { | ||
this.setAttribute('foo', 'bar'); | ||
} | ||
} | ||
MyComponent.publicMethods = ['setFoo']; | ||
Child.publicMethods = ['setFoo']; | ||
|
||
class Parent extends Element { | ||
render() { | ||
return ($api) => { | ||
return [$api.c('should-set-attribute-on-host-element-when-element-is-nested-in-template-child', MyComponent, {})] | ||
return [$api.c('x-child', Child, {})] | ||
} | ||
} | ||
} | ||
const element = createElement('should-set-attribute-on-host-element-when-element-is-nested-in-template', { is: Parent }); | ||
document.body.appendChild(element); | ||
const child = querySelector.call(element, 'should-set-attribute-on-host-element-when-element-is-nested-in-template-child'); | ||
const child = querySelector.call(element, 'x-child'); | ||
child.setFoo(); | ||
expect(child.hasAttribute('foo')).toBe(true); | ||
expect(child.getAttribute('foo')).toBe('bar'); | ||
|
@@ -111,17 +112,17 @@ describe('html-element', () => { | |
|
||
describe('#removeAttributeNS()', () => { | ||
it('should remove namespaced attribute on host element when element is nested in template', () => { | ||
class MyComponent extends Element { | ||
class Child extends Element { | ||
removeTitle() { | ||
this.removeAttributeNS('x', 'title'); | ||
} | ||
} | ||
MyComponent.publicMethods = ['removeTitle']; | ||
Child.publicMethods = ['removeTitle']; | ||
|
||
class Parent extends Element { | ||
render() { | ||
return ($api) => { | ||
return [$api.c('remove-namespaced-attribute-on-host-element-child', MyComponent, { | ||
return [$api.c('x-child', Child, { | ||
attrs: { | ||
'x:title': 'foo', | ||
} | ||
|
@@ -131,7 +132,7 @@ describe('html-element', () => { | |
} | ||
const element = createElement('remove-namespaced-attribute-on-host-element', { is: Parent }); | ||
document.body.appendChild(element); | ||
const child = querySelector.call(element, 'remove-namespaced-attribute-on-host-element-child'); | ||
const child = querySelector.call(element, 'x-child'); | ||
child.removeTitle(); | ||
expect(child.hasAttributeNS('x', 'title')).toBe(false); | ||
}); | ||
|
@@ -152,17 +153,17 @@ describe('html-element', () => { | |
|
||
describe('#removeAttribute()', () => { | ||
it('should remove attribute on host element when element is nested in template', () => { | ||
class MyComponent extends Element { | ||
class Child extends Element { | ||
removeTitle() { | ||
this.removeAttribute('title'); | ||
} | ||
} | ||
MyComponent.publicMethods = ['removeTitle']; | ||
Child.publicMethods = ['removeTitle']; | ||
|
||
class Parent extends Element { | ||
render() { | ||
return ($api) => { | ||
return [$api.c('element-is-nested-in-template-child', MyComponent, { | ||
return [$api.c('x-child', Child, { | ||
attrs: { | ||
title: 'foo', | ||
} | ||
|
@@ -172,7 +173,7 @@ describe('html-element', () => { | |
} | ||
const element = createElement('element-is-nested-in-template', { is: Parent }); | ||
document.body.appendChild(element); | ||
const child = querySelector.call(element, 'element-is-nested-in-template-child'); | ||
const child = querySelector.call(element, 'x-child'); | ||
child.removeTitle(); | ||
expect(child.hasAttribute('title')).toBe(false); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you changing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it not to conflict with line 70, one of the children of
x-boundary
is also ax-boundary
but with a different class. The engine logs a warning because of this.