Testing attributes
Example Custom Attribute
import { bindable, customAttribute, INode, resolve } from 'aurelia';
@customAttribute('color-square')
export class ColorSquareCustomAttribute {
@bindable color: string = 'red';
@bindable size: string = '100px';
private element: HTMLElement = resolve(INode)
constructor() {
this.element.style.width = this.size;
this.element.style.height = this.size;
this.element.style.backgroundColor = this.color;
}
bound() {
this.element.style.width = this.size;
this.element.style.height = this.size;
this.element.style.backgroundColor = this.color;
}
colorChanged(newColor: string) {
this.element.style.backgroundColor = newColor;
}
sizeChanged(newSize: string) {
this.element.style.width = newSize;
this.element.style.height = newSize;
}
}Testing the Custom Attribute
Test Setup
Writing Tests
Testing Approach
Conclusion
Last updated
Was this helpful?