-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mon-pix): display reward tab only if there is at least an acquire…
…d or an always visible badge
- Loading branch information
Showing
2 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
.../tests/unit/components/campaigns/assessment/results/evaluation-results-tabs/index-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
import createGlimmerComponent from '../../../../../../helpers/create-glimmer-component'; | ||
|
||
module( | ||
'Unit | Component | Campaigns | Assessment | Results | EvaluationResultsTabs | ResultsDetails | CompetenceRow', | ||
function (hooks) { | ||
setupTest(hooks); | ||
|
||
module('#showRewardsTab', function () { | ||
module('when there is no badge', function () { | ||
test('should return false', async function (assert) { | ||
// given | ||
const component = createGlimmerComponent('campaigns/assessment/results/evaluation-results-tabs/index'); | ||
|
||
component.args.campaignParticipationResult = { | ||
campaignParticipationBadges: [], | ||
}; | ||
|
||
// then | ||
assert.false(component.showRewardsTab); | ||
}); | ||
}); | ||
|
||
module('when there is badges', function () { | ||
module('when there is only not-acquired and no always visible badge', function () { | ||
test('should return false', async function (assert) { | ||
// given | ||
const store = this.owner.lookup('service:store'); | ||
const notAlwaysVisibledBadge = store.createRecord('campaign-participation-badge', { | ||
isAcquired: false, | ||
isAlwaysVisible: false, | ||
}); | ||
|
||
const component = createGlimmerComponent('campaigns/assessment/results/evaluation-results-tabs/index'); | ||
|
||
component.args.campaignParticipationResult = { | ||
campaignParticipationBadges: [notAlwaysVisibledBadge], | ||
}; | ||
|
||
// then | ||
assert.false(component.showRewardsTab); | ||
}); | ||
}); | ||
|
||
module('when there is at least a not-acquired but always visible badge', function () { | ||
test('should return true', async function (assert) { | ||
// given | ||
const store = this.owner.lookup('service:store'); | ||
const alwaysVisibledBadge = store.createRecord('campaign-participation-badge', { | ||
isAcquired: false, | ||
isAlwaysVisible: true, | ||
}); | ||
|
||
const component = createGlimmerComponent('campaigns/assessment/results/evaluation-results-tabs/index'); | ||
|
||
component.args.campaignParticipationResult = { | ||
campaignParticipationBadges: [alwaysVisibledBadge], | ||
}; | ||
|
||
// then | ||
assert.true(component.showRewardsTab); | ||
}); | ||
}); | ||
|
||
module('when there is at least one acquired badge', function () { | ||
test('should return true', async function (assert) { | ||
// given | ||
const store = this.owner.lookup('service:store'); | ||
const acquiredBadge = store.createRecord('campaign-participation-badge', { | ||
isAcquired: true, | ||
}); | ||
|
||
const component = createGlimmerComponent('campaigns/assessment/results/evaluation-results-tabs/index'); | ||
|
||
component.args.campaignParticipationResult = { | ||
campaignParticipationBadges: [acquiredBadge], | ||
}; | ||
|
||
// then | ||
assert.true(component.showRewardsTab); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}, | ||
); |