|
1 | 1 | import { describe, it, expect, vi } from 'vitest'; |
2 | | -import { isManifestAvailable } from './is-manifest-available.ts'; |
| 2 | +import { getManifestStatus } from './is-manifest-available.ts'; |
3 | 3 | import type { Options } from 'storybook/internal/types'; |
4 | 4 |
|
5 | 5 | function createMockOptions({ |
@@ -28,44 +28,43 @@ function createMockOptions({ |
28 | 28 | } as unknown as Options; |
29 | 29 | } |
30 | 30 |
|
31 | | -describe('isManifestAvailable', () => { |
| 31 | +describe('getManifestStatus', () => { |
32 | 32 | it.each([ |
33 | 33 | { |
34 | 34 | description: 'both feature flag and generator are present', |
35 | 35 | options: { featureFlag: true, hasGenerator: true }, |
36 | | - expected: true, |
| 36 | + expected: { available: true, hasGenerator: true, hasFeatureFlag: true }, |
37 | 37 | }, |
38 | 38 | { |
39 | | - description: 'feature flag is disabled', |
40 | | - options: { featureFlag: false, hasGenerator: true }, |
41 | | - expected: false, |
| 39 | + description: 'missing generator (unsupported framework)', |
| 40 | + options: { featureFlag: true, hasGenerator: false }, |
| 41 | + expected: { available: false, hasGenerator: false, hasFeatureFlag: true }, |
42 | 42 | }, |
43 | 43 | { |
44 | | - description: 'generator is not configured', |
45 | | - options: { featureFlag: true, hasGenerator: false }, |
46 | | - expected: false, |
| 44 | + description: 'missing feature flag', |
| 45 | + options: { featureFlag: false, hasGenerator: true }, |
| 46 | + expected: { available: false, hasGenerator: true, hasFeatureFlag: false }, |
47 | 47 | }, |
48 | 48 | { |
49 | 49 | description: 'both are missing', |
50 | 50 | options: { featureFlag: false, hasGenerator: false }, |
51 | | - expected: false, |
| 51 | + expected: { |
| 52 | + available: false, |
| 53 | + hasGenerator: false, |
| 54 | + hasFeatureFlag: false, |
| 55 | + }, |
52 | 56 | }, |
53 | 57 | { |
54 | 58 | description: 'features object is missing the flag', |
55 | 59 | options: { hasGenerator: true, hasFeaturesObject: false }, |
56 | | - expected: false, |
| 60 | + expected: { available: false, hasGenerator: true, hasFeatureFlag: false }, |
57 | 61 | }, |
58 | 62 | ])( |
59 | | - 'should return $expected when $description', |
| 63 | + 'should return correct status when $description', |
60 | 64 | async ({ options, expected }) => { |
61 | 65 | const mockOptions = createMockOptions(options); |
62 | | - const result = await isManifestAvailable(mockOptions); |
63 | | - |
64 | | - if (expected) { |
65 | | - expect(result).toBeTruthy(); |
66 | | - } else { |
67 | | - expect(result).toBeFalsy(); |
68 | | - } |
| 66 | + const result = await getManifestStatus(mockOptions); |
| 67 | + expect(result).toEqual(expected); |
69 | 68 | }, |
70 | 69 | ); |
71 | 70 | }); |
0 commit comments