Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Allow generation of Identifier field in Playground if no validation needed #2521

Merged
merged 1 commit into from
Nov 1, 2017

Conversation

samjsmith
Copy link
Contributor

No description provided.

Copy link
Contributor

@bestbeforetoday bestbeforetoday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only "showstopper" is an unused variable. Your call on whether other changes are the right thing to do.

@@ -174,6 +175,7 @@ describe('ResourceComponent', () => {
describe('#generateResource', () => {
let mockClassDeclaration;
let mockModelFile;
let mockValidator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

it('should generate a valid resource with an empty ID', () => {
let mockField = {
getValidator: () => {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should return a String?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

return true;
}
};
mockClassDeclaration.getOwnProperty.returns(mockField);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know the identifier field name (in the beforeEach) so might be worth pulling that out to a variable and using mockClassDeclaration.getOwnProperty.calledWith(idFieldName).returns(mockField);. This is saying that all field names exist and return the same mock, but maybe that's OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

return false;
}
};
mockClassDeclaration.getOwnProperty.returns(mockField);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

return false;
}
};
mockClassDeclaration.getOwnProperty.returns(mockField);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

return false;
}
};
mockClassDeclaration.getOwnProperty.returns(mockField);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz re-review

@@ -289,7 +295,51 @@ describe('ResourceComponent', () => {

});

it('should generate a valid resource with a random 4-digit ID', () => {
let mockField = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth creating a Sinon stub instance of Field just as a safety net to make sure the function you're stubbing exists -- I think Sinon will complain if you add a returns() to a function it hasn't stubbed through introspection. Maybe that's overkill though. Your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

…uired

As discussed with Simon, removing the code that adds the identifier field name to the
auto generated data for relationships in Asset

Signed-off-by: Sam Smith <smithsj@uk.ibm.com>
@samjsmith samjsmith merged commit d4d1ddf into hyperledger-archives:master Nov 1, 2017
@nklincoln
Copy link
Contributor

🐼 no issue? 🐼

@Nicolas-Ding
Copy link

Is it possible that this broke the automatic generation of the "$class" variable when submitting a transaction ? Since v 0.14.3 the "$class" variable does not change anymore when I select another transaction via the dropdown menu and I was wondering if this can be the cause. Below is a screenshot using one of the basic examples provided in playground :
image

@samjsmith samjsmith deleted the iss2413 branch November 7, 2017 11:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants