-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
113 changed files
with
6,341 additions
and
3,522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
module.exports = { | ||
trailingComma: 'es5', | ||
printWidth: 120, | ||
plugins: ['prettier-plugin-ember-template-tag'], | ||
overrides: [ | ||
{ | ||
files: '*.{js,ts,cjs,cts,mjs,mts}', | ||
options: { | ||
singleQuote: true, | ||
}, | ||
}, | ||
{ | ||
files: ['*.hbs'], | ||
options: { | ||
singleQuote: false, | ||
}, | ||
}, | ||
{ | ||
files: ['*.gjs', '*.gts'], | ||
options: { | ||
parser: 'ember-template-tag', | ||
singleQuote: true, | ||
templateSingleQuote: false, | ||
trailingComma: 'es5', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function cached(target: object, key: string, desc: PropertyDescriptor): void; | ||
|
||
export function tracked(target: object, key: string): void; | ||
export function tracked(target: object, key: string, desc?: object): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import type { ModuleCallback, ModuleInfo, OrderedMap, TestCallback, TestContext, TestInfo } from './-types'; | ||
import { assert, generateHash } from './-utils'; | ||
import { Config, getCurrentModule, HooksDelegate, setCurrentModule } from './internals/config'; | ||
|
||
export { registerReporter } from './internals/delegating-reporter'; | ||
export { setupGlobalHooks, configure } from './internals/config'; | ||
export { PublicTestInfo } from './internals/run'; | ||
|
||
export const Modules: OrderedMap<ModuleInfo<TestContext>> = { | ||
byName: new Map(), | ||
byOrder: [], | ||
}; | ||
|
||
export type { Diagnostic, Hooks as NestedHooks, GlobalHooks, TestContext } from './-types'; | ||
|
||
export function module<TC extends TestContext = TestContext>(name: string, cb: ModuleCallback<TC>): void { | ||
const parentModule = getCurrentModule<TC>() ?? null; | ||
let moduleName = name; | ||
if (parentModule) { | ||
moduleName = `${parentModule.name} > ${name}`; | ||
} else { | ||
Config.totals.primaryModules++; | ||
} | ||
Config.totals.modules++; | ||
|
||
assert(`Cannot add the same module name twice: ${moduleName}`, !Modules.byName.has(moduleName)); | ||
const moduleConfig: ModuleInfo<TC>['config'] = { | ||
beforeEach: [], | ||
afterEach: [], | ||
beforeModule: [], | ||
afterModule: [], | ||
}; | ||
const tests: OrderedMap<TestInfo<TC>> = { byName: new Map(), byOrder: [] }; | ||
const modules: OrderedMap<ModuleInfo<TC>> = { byName: new Map(), byOrder: [] }; | ||
const moduleInfo = { | ||
moduleName, | ||
name, | ||
cb, | ||
config: moduleConfig, | ||
tests, | ||
modules, | ||
parent: parentModule, | ||
}; | ||
|
||
setCurrentModule(moduleInfo); | ||
|
||
if (parentModule) { | ||
parentModule.modules.byName.set(name, moduleInfo); | ||
parentModule.modules.byOrder.push(moduleInfo); | ||
} else { | ||
// @ts-expect-error TS poorly handles subtype constraints | ||
Modules.byName.set(name, moduleInfo); | ||
// @ts-expect-error TS poorly handles subtype constraints | ||
Modules.byOrder.push(moduleInfo); | ||
} | ||
|
||
cb(HooksDelegate); | ||
setCurrentModule(parentModule as unknown as ModuleInfo<TC>); | ||
} | ||
|
||
export function test<TC extends TestContext = TestContext>(name: string, cb: TestCallback<TC>): void { | ||
const currentModule = getCurrentModule<TC>(); | ||
assert(`Cannot add a test outside of a module`, !!currentModule); | ||
assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name)); | ||
Config.totals.tests++; | ||
|
||
const testInfo = { | ||
id: generateHash(currentModule.moduleName + ' > ' + name), | ||
name, | ||
cb, | ||
skip: false, | ||
todo: false, | ||
module: currentModule, | ||
}; | ||
|
||
currentModule.tests.byName.set(name, testInfo); | ||
currentModule.tests.byOrder.push(testInfo); | ||
} | ||
|
||
export function todo<TC extends TestContext = TestContext>(name: string, cb: TestCallback<TC>): void { | ||
const currentModule = getCurrentModule<TC>(); | ||
assert(`Cannot add a test outside of a module`, !!currentModule); | ||
assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name)); | ||
Config.totals.todo++; | ||
|
||
const testInfo = { | ||
id: generateHash(currentModule.moduleName + ' > ' + name), | ||
name, | ||
cb, | ||
skip: false, | ||
todo: true, | ||
module: currentModule, | ||
}; | ||
|
||
currentModule.tests.byName.set(name, testInfo); | ||
currentModule.tests.byOrder.push(testInfo); | ||
} | ||
|
||
export function skip<TC extends TestContext = TestContext>(name: string, cb: TestCallback<TC>): void { | ||
const currentModule = getCurrentModule<TC>(); | ||
assert(`Cannot add a test outside of a module`, !!currentModule); | ||
assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name)); | ||
Config.totals.skipped++; | ||
|
||
const testInfo = { | ||
id: generateHash(currentModule.moduleName + ' > ' + name), | ||
name, | ||
cb, | ||
skip: true, | ||
todo: false, | ||
module: currentModule, | ||
}; | ||
|
||
currentModule.tests.byName.set(name, testInfo); | ||
currentModule.tests.byOrder.push(testInfo); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @ts-expect-error: types for this API is not consistently available (via transitive | ||
// deps) and we do not currently want to make it an explicit dependency. It | ||
// does, however, consistently work at runtime. :sigh: | ||
import { getInternalComponentManager as getComponentManager } from '@glimmer/manager'; | ||
|
||
export type ComponentLike = object; | ||
|
||
/** | ||
* We should ultimately get a new API from @glimmer/runtime that provides this functionality | ||
* (see https://github.com/emberjs/rfcs/pull/785 for more info). | ||
* @private | ||
* @param {Object} maybeComponent The thing you think might be a component | ||
* @returns {boolean} True if it's a component, false if not | ||
*/ | ||
function isComponent(maybeComponent: object): maybeComponent is ComponentLike { | ||
return !!getComponentManager(maybeComponent, true); | ||
} | ||
|
||
export default isComponent; |
Oops, something went wrong.