CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 12
Row with unit tests, styling, and interfaces #7
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7 +/- ##
=======================================
+ Coverage 51.72% 60% +8.27%
=======================================
Files 4 7 +3
Lines 29 55 +26
Branches 1 3 +2
=======================================
+ Hits 15 33 +18
- Misses 14 22 +8
Continue to review full report at Codecov.
|
src/Row.ts
Outdated
} | ||
|
||
@theme(rowClasses) | ||
class Row extends ThemeableMixin(RegistryMixin(WidgetBase))<RowProperties> { |
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.
When using mixins we need to declare the base type as a const
before using it to extend.
export type RowBase = ThemeableMixin(RegistryMixin(WidgetBase));
class Row extends RowBase<RowProperties> {
// .....
}
Also there is an extra space.
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.
Is there more info on what causes 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.
What do you mean by an extra space?
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.
There's lots of info in the dojo 2 room and I also raised an issue on typescript, I don't have the link to hand (I'll add later).
Basically you cannot extend an expression, which Mixin(Class)<Properties>
actually is. With the release of 2.2.1 this would actually fail to create the d.ts file when running grunt dist
.
There's an extra space after Row
and before extends
... just killing my OCD.
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.
Ahh, cool. Yeah, I hate extra spaces too just was blind to it.
tests/unit/Row.ts
Outdated
item: { foo: 'bar' } | ||
}; | ||
|
||
const rowVie = new Row(); |
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.
What is a rowVie
?
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.
Ha
@@ -1 +1,2 @@ | |||
@import 'row.css'; |
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 don't think this file is needed. Unless you add an exception to the grunt-dojo2 rules for this project this will be built into a css-module file but the generated class names will not line up with those used on the widgets.
} | ||
|
||
.rowTable { | ||
composes: rowTable from './shared/rowTable.css'; |
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 does rowtable need to be in a separate css file? Is it used elsewhere?
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.
Yes, it's also used in the header
src/Row.ts
Outdated
classes: this.classes(rowClasses.rowTable) | ||
}, [ | ||
v('tr', columns.map(({ id, field }) => { | ||
return w('cell', <CellProperties> { |
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.
Do you need to cast here?
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 think this is the only way to ensure I obey that interface
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.
Can you not do w<CellProperties>('cell', { ... })
?
src/Row.ts
Outdated
import * as rowClasses from './styles/row.css'; | ||
|
||
export interface RowProperties extends WidgetProperties, HasColumns, RegistryMixinProperties { | ||
item: any; |
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.
Could there be any benefit from making this generic, or at least providing a base type? It looks like the code is assuming that item.data
will exist for example.
The field
properties in the column definitions could even be required to be a member of keyof ItemDataType
or something.
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.
Good catch. I like the field stuff as well. I'm going to make a note to go through and see where I can refine that.
@@ -0,0 +1,47 @@ | |||
import { WidgetProperties } from '@dojo/widget-core/interfaces'; |
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.
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.
Fixed
tests/support/util.ts
Outdated
@@ -16,3 +19,19 @@ export function isEventuallyRejected<T>(promise: Thenable<T>): Thenable<boolean> | |||
export function throwImmediatly() { |
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.
throwImmediatly => throwImmediately
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.
Fixed
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.
Several modules could be improved by using consistent import order per the style guide:
https://github.com/dojo/meta/blob/master/STYLE.md#ordering
Type: feature
The following has been addressed in the PR:
Description:
Adds the Row widget with styling and unit tests. Adds interfaces used by the Row properties.