Skip to content

Commit

Permalink
Add tests for generated getPropKey implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
greglittlefield-wf committed Dec 5, 2023
1 parent 0840751 commit 481269f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ main() {
expect(ComponentTest()..customKeyAndNamespaceProp = 'test',
containsPair('custom namespace~~custom key!', 'test'));
});
});

test('generates a functional getPropKey implementation', () {
expect(ComponentTest().getPropKey((p) => p.stringProp), 'ComponentTestProps.stringProp');
expect(ComponentTest().getPropKey((p) => p.customKeyAndNamespaceProp),
'custom namespace~~custom key!');
});

group('generates componentDefaultProps with', () {
test('default props', () {
expect(ComponentTest().componentDefaultProps, equals({'id':'testId'}));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ main() {
expect(ComponentTest()..customKeyAndNamespaceProp = 'test',
containsPair('custom namespace~~custom key!', 'test'));
});
});

test('generates a functional getPropKey implementation', () {
expect(ComponentTest().getPropKey((p) => p.stringProp), 'ComponentTestProps.stringProp');
expect(ComponentTest().getPropKey((p) => p.customKeyAndNamespaceProp),
'custom namespace~~custom key!');
});

group('generates componentDefaultProps with', () {
test('default props', () {
expect(ComponentTest().componentDefaultProps, equals
({'id':'testId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ main() {
expect(ComponentTest()..customKeyAndNamespaceProp = 'test',
containsPair('custom namespace~~custom key!', 'test'));
});
});

test('generates a functional getPropKey implementation', () {
expect(ComponentTest().getPropKey((p) => p.stringProp), 'ComponentTestProps.stringProp');
expect(ComponentTest().getPropKey((p) => p.customKeyAndNamespaceProp),
'custom namespace~~custom key!');
});

group('generates componentDefaultProps with', () {
test('default props', () {
expect(ComponentTest().componentDefaultProps, equals
({'id':'testId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ void functionComponentTestHelper(UiFactory<TestProps> factory,
});
});

test('generates a functional getPropKey implementation', () {
expect(factory().getPropKey((p) => p.stringProp), 'TestPropsMixin.stringProp');
expect(factory().getPropKey((p) => p.customKeyAndNamespaceProp),
'custom namespace~~custom key!');
});

group('can pass along unconsumed props', () {
const stringProp = 'a string';
const anotherProp = 'this should be filtered';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ main() {
expect(Test()..customKeyAndNamespaceProp = 'test',
containsPair('custom namespace~~custom key!', 'test'));
});
});

test('returns an empty map for componentDefaultProps', () {
expect(Test().componentDefaultProps, equals({}));
});
test('generates a functional getPropKey implementation', () {
expect(Test().getPropKey((p) => p.stringProp), 'TestProps.stringProp');
expect(
Test().getPropKey((p) => p.customKeyAndNamespaceProp), 'custom namespace~~custom key!');
});

test('generates componentDefaultProps that returns an empty map', () {
expect(Test().componentDefaultProps, equals({}));
});

test('raises an assertion when invoked via call/build, since it has no componentFactory', () {
Expand Down

0 comments on commit 481269f

Please sign in to comment.