Primeiro commit do projeto Angular
This commit is contained in:
+138
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
/**
|
||||
* @fileoverview This file is the single source of truth for all "TODO" notes
|
||||
* generated by the Jasmine to Vitest schematic.
|
||||
*
|
||||
* It defines the `TODO_NOTES` constant, which contains the message and optional
|
||||
* documentation URL for each category of manual migration task.
|
||||
*
|
||||
* The file also exports advanced mapped types (`TodoCategory`, `TodoContextMap`)
|
||||
* that are inferred directly from the `TODO_NOTES` object. This creates a
|
||||
* maintainable, type-safe system that ensures consistency across all
|
||||
* transformers and prevents runtime errors.
|
||||
*/
|
||||
/**
|
||||
* The central configuration for all "TODO" notes. Each key represents a unique
|
||||
* `TodoCategory`.
|
||||
*
|
||||
* Each entry is an object with:
|
||||
* - `message`: A string or a function that returns a string. If it's a function,
|
||||
* it receives a `context` object to generate a dynamic message.
|
||||
* - `url`: An optional documentation URL that will be appended to the message.
|
||||
*/
|
||||
export declare const TODO_NOTES: {
|
||||
readonly pending: {
|
||||
readonly message: "The pending() function was converted to a skipped test (`it.skip`).";
|
||||
readonly url: "https://vitest.dev/api/vi.html#it-skip";
|
||||
};
|
||||
readonly toHaveSpyInteractions: {
|
||||
readonly message: string;
|
||||
};
|
||||
readonly toThrowMatching: {
|
||||
readonly message: (context: {
|
||||
name: string;
|
||||
}) => string;
|
||||
readonly url: "https://vitest.dev/api/expect.html#tothrowerror";
|
||||
};
|
||||
readonly toBePending: {
|
||||
readonly message: string;
|
||||
};
|
||||
readonly 'unsupported-expect-async-matcher': {
|
||||
readonly message: (context: {
|
||||
name: string;
|
||||
}) => string;
|
||||
};
|
||||
readonly 'arrayWithExactContents-dynamic-variable': {
|
||||
readonly message: "Cannot transform jasmine.arrayWithExactContents with a dynamic variable. Please migrate this manually.";
|
||||
};
|
||||
readonly 'arrayWithExactContents-check': {
|
||||
readonly message: "Verify this matches strict array content (multiset equality). Vitest's arrayContaining is a subset check.";
|
||||
};
|
||||
readonly 'expect-nothing': {
|
||||
readonly message: "expect().nothing() has been removed because it is redundant in Vitest. Tests without assertions pass by default.";
|
||||
};
|
||||
readonly 'unsupported-global-function': {
|
||||
readonly message: (context: {
|
||||
name: string;
|
||||
}) => string;
|
||||
};
|
||||
readonly addMatchers: {
|
||||
readonly message: "jasmine.addMatchers is not supported. Please manually migrate to expect.extend().";
|
||||
readonly url: "https://vitest.dev/api/expect.html#expect-extend";
|
||||
};
|
||||
readonly addCustomEqualityTester: {
|
||||
readonly message: "jasmine.addCustomEqualityTester is not supported. Please manually migrate to expect.addEqualityTesters().";
|
||||
readonly url: "https://vitest.dev/api/expect.html#expect-addequalitytesters";
|
||||
};
|
||||
readonly mapContaining: {
|
||||
readonly message: string;
|
||||
};
|
||||
readonly setContaining: {
|
||||
readonly message: string;
|
||||
};
|
||||
readonly 'unknown-jasmine-property': {
|
||||
readonly message: (context: {
|
||||
name: string;
|
||||
}) => string;
|
||||
};
|
||||
readonly spyOnAllFunctions: {
|
||||
readonly message: string;
|
||||
readonly url: "https://vitest.dev/api/vi.html#vi-spyon";
|
||||
};
|
||||
readonly 'createSpyObj-single-argument': {
|
||||
readonly message: "jasmine.createSpyObj called with a single argument is not supported for transformation.";
|
||||
readonly url: "https://vitest.dev/api/vi.html#vi-fn";
|
||||
};
|
||||
readonly 'createSpyObj-dynamic-variable': {
|
||||
readonly message: "Cannot transform jasmine.createSpyObj with a dynamic variable. Please migrate this manually.";
|
||||
readonly url: "https://vitest.dev/api/vi.html#vi-fn";
|
||||
};
|
||||
readonly 'createSpyObj-dynamic-property-map': {
|
||||
readonly message: "Cannot transform jasmine.createSpyObj with a dynamic property map. Please migrate this manually.";
|
||||
readonly url: "https://vitest.dev/api/vi.html#vi-fn";
|
||||
};
|
||||
readonly 'unsupported-spy-strategy': {
|
||||
readonly message: (context: {
|
||||
name: string;
|
||||
}) => string;
|
||||
readonly url: "https://vitest.dev/api/mocked.html#mock";
|
||||
};
|
||||
readonly 'mostRecent-without-args': {
|
||||
readonly message: string;
|
||||
readonly url: "https://vitest.dev/api/mocked.html#mock-lastcall";
|
||||
};
|
||||
readonly 'unhandled-done-usage': {
|
||||
readonly message: "The 'done' callback was used in an unhandled way. Please migrate manually.";
|
||||
};
|
||||
};
|
||||
/**
|
||||
* A union type of all possible "TODO" categories.
|
||||
* It is derived from the keys of the `TODO_NOTES` object to ensure that only
|
||||
* valid categories can be used throughout the transformers.
|
||||
*/
|
||||
export type TodoCategory = keyof typeof TODO_NOTES;
|
||||
/**
|
||||
* A mapped type that creates a map from a `TodoCategory` to the type of the
|
||||
* context object that its message function expects. This provides strong type
|
||||
* safety for calls to `addTodoComment`.
|
||||
*
|
||||
* It works by checking if the `message` property for a given category is a
|
||||
* function. If it is, it uses `infer` to extract the type of the first
|
||||
* parameter (`P`). If it's not a function, it resolves to `never`.
|
||||
*
|
||||
* @example
|
||||
* // `Context` will be `{ name: string }`
|
||||
* type Context = TodoContextMap['unknown-jasmine-property'];
|
||||
*
|
||||
* // `Context` will be `never`
|
||||
* type Context = TodoContextMap['pending'];
|
||||
*/
|
||||
export type TodoContextMap = {
|
||||
[K in TodoCategory]: (typeof TODO_NOTES)[K]['message'] extends (context: infer P) => string ? P : never;
|
||||
};
|
||||
Reference in New Issue
Block a user