Last active
June 5, 2019 15:31
-
-
Save Tallyb/da5ced8675c8b098b8159af2c1ac41a2 to your computer and use it in GitHub Desktop.
Component Logic - Stencil
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
//instance.tsx | |
import { Component, Prop } from '@stencil/core'; | |
@Component({ | |
tag: 'my-instance' | |
}) | |
export class MyInstance { | |
/** | |
* The first name | |
*/ | |
@Prop() first: string; | |
/** | |
* The middle name | |
*/ | |
@Prop() middle: string; | |
/** | |
* The last name | |
*/ | |
@Prop() last: string; | |
format () { | |
return [this.first, this.middle, this.last].filter (e => !!e).join(' '); | |
} | |
} | |
// instance.spec.ts | |
import { MyInstance } from './instance'; | |
it ('Should format the name', () => { | |
let cmp = new MyInstance(); | |
cmp.first = 'Donald'; | |
cmp.last = 'Duck'; | |
expect(cmp.format()).toEqual('Donald Duck'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment