Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up tests for "lb4 relation" command #3748

Merged
merged 6 commits into from
Sep 17, 2019
Merged

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Sep 16, 2019

In this pull request I am significantly cleaning up integration tests for lb4 relation command. It's best to review the changes one commit at a time, I recommend to ignore white-space changes too.

List of commits/changes:

  • refactor "fixtures/relation" to reduce code duplication
  • rename files to follow the pattern relation.{type}.integration.ts
  • move relation-type-specific tests from relation.integration.ts to relation-type-specific test files
  • improve readability of tests by inlining (some of) SANDBOX_FILES{n}
  • improve structure of relation.has-many.integration.js and relation.belongs-to.integration.js by fixing nesting of describe and context blocks and grouping parameterized groups into describe blocks with a descriptive titles generated from the parameter values
  • fix incorrect callback usage (a small fix)

This pull request is a follow-up for #3716 (comment).

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

- rename files to follow the pattern `relation.{type}.integration.ts`
- move relation-type-specific tests from `relation.integration.ts`
  to relation-type-specific test files

Signed-off-by: Miroslav Bajtoš <[email protected]>
Replace variables like `SANDBOX_FILES6` with an array of source files
to copy. This makes the tests easier to read. The name `SANDBOX_FILES6`
does not say anything about the files in the array, while a list
of files like `CustomerModelWithOrdersProperty` makes the intent clear.

Signed-off-by: Miroslav Bajtoš <[email protected]>
Copy link
Contributor

@agnes512 agnes512 left a comment

Choose a reason for hiding this comment

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

LGYM, especially you comment the change in the relation.integration.js file:

// In this test suite, we test scenarios that apply to all relation types
// See relation-{type}.integration.ts files for test cases specific
// to different relation types.

Copy link
Contributor

@nabdelgadir nabdelgadir left a comment

Choose a reason for hiding this comment

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

👏


const sandbox = new TestSandbox(SANDBOX_PATH);

const hasManyrImportRegEx = /import \{Entity, model, property, hasMany\} from '@loopback\/repository';\n/;
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the r in hasManyrImportRegEx for?

Copy link
Contributor

Choose a reason for hiding this comment

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

probably a typo

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's probably a typo, this line was copied with no changes.

@bajtos bajtos merged commit 9c01f2c into master Sep 17, 2019
@bajtos bajtos deleted the refactor/cli-relation-tests branch September 17, 2019 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants