@mintlify/previewing
Version:
Preview Mintlify docs locally
24 lines (23 loc) • 1.18 kB
JavaScript
import path from 'path';
import { getLocalGraphqlSources, shouldRegenerateGraphqlSource, } from '../local-preview/listener/referencedFiles.js';
describe('getLocalGraphqlSources', () => {
it('tracks configured local schema paths regardless of extension', () => {
expect(getLocalGraphqlSources({
navigation: {
tabs: [
{
tab: 'API',
graphql: { source: '/schemas/./nested/../schema.custom', directory: 'api' },
},
{ tab: 'Remote', graphql: 'HTTPS://example.com/schema.graphql' },
],
},
})).toEqual([path.normalize('schemas/schema.custom')]);
});
it('rebuilds only configured GraphQL sources', () => {
const configuredSources = new Set([path.normalize('schemas/schema.custom')]);
expect(shouldRegenerateGraphqlSource('/schemas/./schema.custom', configuredSources)).toBe(true);
expect(shouldRegenerateGraphqlSource('schema.graphql', configuredSources)).toBe(false);
expect(shouldRegenerateGraphqlSource('unrelated.txt', configuredSources)).toBe(false);
});
});