dojo / test-extras

:rocket: Dojo 2 - set of modules to help with testing Dojo.
http://dojo.io
Other
0 stars 14 forks source link

widget.expectRender report failure messages when use style in properties #100

Closed xiaohulu closed 6 years ago

xiaohulu commented 6 years ago

Enhancement Package Version: 0.4.1

Code

when style value is different, the assert failure message is misleading.

widget render method. https://github.com/xiaohulu/dojo2-demo/blob/master/src/widgets/TestedWidget.ts

    protected render(){
        return v('div', {
               classes: this.theme(css.root), style:'height:120px'
        }, ['Test Widget']);
}

test method https://github.com/xiaohulu/dojo2-demo/blob/master/tests/unit/widgets/TestedWidget.ts

        'harness test'() {
            let widget = harness(TestedWidget);
            widget.expectRender(v('div', {
                classes: css.root,
                style: 'height: 120px;' 
            },['Test Widget']))
        }

failure messages

× node - TestedWidget - harness test (0s)
    AssertionError: Render unexpected: Properties do not match

      {
    A   "classes": "_1Ic5WoWt",
    A   "style": "height:120px"
    E   "classes": {},
    E   "style": "height: 120px;"
      }

      at Projector../node_modules/@dojo/test-extras/harness.js.WidgetHarness.actualRender  <webpack:\node_modules\@dojo\test-extras\harness.js:146:0>
      at SpyRender.SpyWidgetMixin.SpyRender.spyRender  <webpack:\node_modules\@dojo\test-extras\harness.js:106:0>
      at <webpack:\node_modules\@dojo\widget-core\WidgetBase.js:421:0>
      at Array.reduce  <anonymous>
      at SpyRender../node_modules/@dojo/widget-core/WidgetBase.js.WidgetBase.runAfterRenders  <webpack:\node_modules\@dojo\widget-core\WidgetBase.js:420:0>
      at SpyRender../node_modules/@dojo/widget-core/WidgetBase.js.WidgetBase.__render__  <webpack:\node_modules\@dojo\widget-core\WidgetBase.js:231:0>
      at createDom  <webpack:\node_modules\@dojo\widget-core\vdom.js:588:0>
      at addChildren  <webpack:\node_modules\@dojo\widget-core\vdom.js:550:0>
      at initPropertiesAndChildren  <webpack:\node_modules\@dojo\widget-core\vdom.js:555:0>
      at createDom  <webpack:\node_modules\@dojo\widget-core\vdom.js:638:0>

Expected behavior:

Make the assertion messages more accurate.

Actual behavior:

The assert failure message is misleading.

agubler commented 6 years ago

This has been addressed with the new implementation #102