mocks.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import type * as d from '@stencil/core/internal';
  2. import { TestingLogger } from './testing-logger';
  3. import { TestingSystem } from './testing-sys';
  4. /**
  5. * Creates a mock instance of an internal, validated Stencil configuration object
  6. * the caller
  7. * @param overrides a partial implementation of `ValidatedConfig`. Any provided fields will override the defaults
  8. * provided by this function.
  9. * @returns the mock Stencil configuration
  10. */
  11. export declare function mockValidatedConfig(overrides?: Partial<d.ValidatedConfig>): d.ValidatedConfig;
  12. /**
  13. * Creates a mock instance of a Stencil configuration entity. The mocked configuration has no guarantees around the
  14. * types/validity of its data.
  15. * @param overrides a partial implementation of `UnvalidatedConfig`. Any provided fields will override the defaults
  16. * provided by this function.
  17. * @returns the mock Stencil configuration
  18. */
  19. export declare function mockConfig(overrides?: Partial<d.UnvalidatedConfig>): d.UnvalidatedConfig;
  20. /**
  21. * Creates a configuration object used to bootstrap a Stencil task invocation
  22. *
  23. * Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
  24. * generation function operates under the assumption that entities like loggers and compiler system abstractions will
  25. * be shared by multiple entities in a test suite, who should provide those entities to this function
  26. *
  27. * @param overrides the properties on the default entity to manually override
  28. * @returns the default configuration initialization object, with any overrides applied
  29. */
  30. export declare const mockLoadConfigInit: (overrides?: Partial<d.LoadConfigInit>) => d.LoadConfigInit;
  31. export declare function mockCompilerCtx(config?: d.ValidatedConfig): d.CompilerCtx;
  32. export declare function mockBuildCtx(config?: d.ValidatedConfig, compilerCtx?: d.CompilerCtx): d.BuildCtx;
  33. export declare function mockLogger(): TestingLogger;
  34. /**
  35. * Create a {@link d.CompilerSystem} entity for testing the compiler.
  36. *
  37. * This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
  38. * place in the codebase where we might expect Stencil engineers to reach for when attempting to mock a
  39. * {@link d.CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
  40. * reconsider if this wrapper is necessary.
  41. *
  42. * @returns a System instance for testing purposes.
  43. */
  44. export declare function mockCompilerSystem(): TestingSystem;
  45. export declare function mockDocument(html?: string | null): Document;
  46. export declare function mockWindow(html?: string): Window;
  47. /**
  48. * This gives you a mock Module, an interface which is the internal compiler
  49. * representation of a module. It includes a bunch of information necessary for
  50. * compilation, this mock basically sets sane defaults for all those values.
  51. *
  52. * @param mod is an override module that you can supply to set particular values
  53. * @returns a module object ready to use in tests!
  54. */
  55. export declare const mockModule: (mod?: Partial<d.Module>) => d.Module;