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

Add unit tests for the ComputedProperty class #20826

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Oleari19
Copy link

@Oleari19 Oleari19 commented Jan 16, 2025

Description:
This pull request introduces a new file, computed-property-test.js, which adds unit tests for the get method of the ComputedProperty class. These tests validate different scenarios and edge cases to ensure proper behavior of the get method when interacting with computed properties in Ember.js.

Test Cases:
CT1: Validates that get returns undefined when the revision is not set, and validateTag returns false.
CT2: Ensures get returns the expected computed value when the revision is set, and validateTag returns false.
CT3: Confirms get returns the computed value when the revision is not set, but validateTag returns true.
CT4: Validates the behavior when dependent keys are present, and validateTag returns false.
CT5: Tests get when the computed property returns an array value.

Simulated Conditions:
Used helper functions such as metaFor, tagFor, tagMetaFor, and validateTag to simulate metadata and tag-related behaviors.

Assertions:
Each test uses assert methods like equal and deepEqual to confirm that the returned values match the expected outcomes.

Purpose:

These tests enhance the coverage and reliability of the ComputedProperty class, ensuring its behavior aligns with expected results under various conditions.

@kategengler
Copy link
Member

Computeds are extensively unit tested already https://github.com/emberjs/ember.js/blob/main/packages/%40ember/-internals/metal/tests/computed_test.js

Computed properties, while not yet deprecated, are a part of the classic Ember Object model and are replaced by @tracked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants