|
| 1 | +import {assert, fixture} from '@open-wc/testing'; |
| 2 | +import {html} from 'lit'; |
| 3 | +import {ChromedashFeatureDetail} from './chromedash-feature-detail'; |
| 4 | +import { |
| 5 | + GATE_PREPARING, |
| 6 | + GATE_REVIEW_REQUESTED, |
| 7 | + VOTE_OPTIONS, |
| 8 | +} from './form-field-enums'; |
| 9 | + |
| 10 | +describe('chromedash-feature-detail', () => { |
| 11 | + const stageNoGates = {id: 1}; |
| 12 | + const stagePreparing = {id: 2}; |
| 13 | + const stageActive = {id: 3}; |
| 14 | + const stageMixed = {id: 4}; |
| 15 | + const stageResolved = {id: 5}; |
| 16 | + |
| 17 | + const gates = [ |
| 18 | + {stage_id: stagePreparing.id, state: GATE_PREPARING}, |
| 19 | + {stage_id: stageActive.id, state: GATE_PREPARING}, |
| 20 | + {stage_id: stageActive.id, state: GATE_REVIEW_REQUESTED}, |
| 21 | + {stage_id: stageMixed.id, state: GATE_PREPARING}, |
| 22 | + {stage_id: stageMixed.id, state: VOTE_OPTIONS.APPROVED[0]}, |
| 23 | + {stage_id: stageResolved.id, state: VOTE_OPTIONS.APPROVED[0]}, |
| 24 | + ]; |
| 25 | + |
| 26 | + const feature = { |
| 27 | + id: 123456789, |
| 28 | + is_enterprise_feature: false, |
| 29 | + stages: [], |
| 30 | + }; |
| 31 | + |
| 32 | + it('renders with mimial data', async () => { |
| 33 | + const component = await fixture( |
| 34 | + html`<chromedash-feature-detail |
| 35 | + .feature=${feature} |
| 36 | + ></chromedash-feature-detail>` |
| 37 | + ); |
| 38 | + assert.exists(component); |
| 39 | + assert.instanceOf(component, ChromedashFeatureDetail); |
| 40 | + }); |
| 41 | + |
| 42 | + it('can identify active gates', async () => { |
| 43 | + const component: ChromedashFeatureDetail = (await fixture( |
| 44 | + html`<chromedash-feature-detail |
| 45 | + .feature=${feature} |
| 46 | + .gates=${gates} |
| 47 | + ></chromedash-feature-detail>` |
| 48 | + )) as ChromedashFeatureDetail; |
| 49 | + assert.isFalse(component.hasActiveGates(stageNoGates)); |
| 50 | + assert.isFalse(component.hasActiveGates(stagePreparing)); |
| 51 | + assert.isTrue(component.hasActiveGates(stageActive)); |
| 52 | + assert.isFalse(component.hasActiveGates(stageMixed)); |
| 53 | + assert.isFalse(component.hasActiveGates(stageResolved)); |
| 54 | + }); |
| 55 | + |
| 56 | + it('can identify mixed gates', async () => { |
| 57 | + const component: ChromedashFeatureDetail = (await fixture( |
| 58 | + html`<chromedash-feature-detail |
| 59 | + .feature=${feature} |
| 60 | + .gates=${gates} |
| 61 | + ></chromedash-feature-detail>` |
| 62 | + )) as ChromedashFeatureDetail; |
| 63 | + assert.isFalse(component.hasMixedGates(stageNoGates)); |
| 64 | + assert.isFalse(component.hasMixedGates(stagePreparing)); |
| 65 | + assert.isFalse(component.hasMixedGates(stageActive)); |
| 66 | + assert.isTrue(component.hasMixedGates(stageMixed)); |
| 67 | + assert.isFalse(component.hasMixedGates(stageResolved)); |
| 68 | + }); |
| 69 | +}); |
0 commit comments