Last active
October 7, 2018 07:39
-
-
Save YonatanKra/de42be2fa5499157169ef141ba377998 to your computer and use it in GitHub Desktop.
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
import {MyCustomElementService} from './my-custom-element.service.ts'; | |
class MyCustomElementMock extends HTMLElement{ | |
config: ConfigModel; | |
constructor() { | |
super(); | |
} | |
} | |
window.customElements.define('my-element', MyCustomElementMock); | |
// now I am testing the service itself | |
describe('custom element service', () => { | |
it('should do something', () => { | |
const service = new MyCustomElementService(); | |
const config = new ConfigModel(); | |
const element = service.doSomething(config); | |
expect(element.config).toEqual(config); | |
}); | |
}); |
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
import {MyCustomElement} from '../customElements/myCustomElement/my-custom-element.ts'; | |
export class MyCustomElementService { | |
doSomething(config) { | |
const myElement = <MyCustomElement>document.createElement('my-element'); //If I inferer the original custom element here, tests won't work as well | |
myElement.config = config; | |
return myElement; | |
} | |
} |
Avinkav
commented
Oct 7, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment