-
Notifications
You must be signed in to change notification settings - Fork 8
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
6 changed files
with
106 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/lib |
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,15 @@ | ||
# @acot/mock | ||
|
||
acot mock modules. | ||
|
||
## Installation | ||
|
||
Install via npm: | ||
|
||
```bash | ||
$ npm install --save @acot/mock | ||
``` | ||
|
||
## Usage | ||
|
||
_T.B.A_ |
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,32 @@ | ||
{ | ||
"name": "@acot/mock", | ||
"version": "0.0.1", | ||
"description": "acot mock modules.", | ||
"homepage": "https://github.com/acot-a11y/acot/tree/main/packages/mock", | ||
"bugs": { | ||
"url": "https://github.com/acot-a11y/acot/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/acot-a11y/acot.git", | ||
"directory": "packages/mock" | ||
}, | ||
"license": "MIT", | ||
"author": "wadackel <wadackel@gmail.com>", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": ["lib", "!__mocks__", "!__tests__"], | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"dependencies": { | ||
"@acot/factory": "0.0.3", | ||
"emittery": "^0.7.1" | ||
}, | ||
"devDependencies": { | ||
"@acot/types": "0.0.3" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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,50 @@ | ||
import type { | ||
Core, | ||
CoreEventMap, | ||
TestDescriptor, | ||
EventListener, | ||
Summary, | ||
} from '@acot/types'; | ||
import { createSummary } from '@acot/factory'; | ||
import Emittery from 'emittery'; | ||
|
||
export class MockCore implements Core { | ||
public version = 'mock'; | ||
public cases: [path: string, descriptor: TestDescriptor][] = []; | ||
public summary: Summary = createSummary(); | ||
public emitter = new Emittery(); | ||
|
||
public add(path: string, descriptor: TestDescriptor): void { | ||
this.cases.push([path, descriptor]); | ||
} | ||
|
||
public async audit(): Promise<Summary> { | ||
this.emitter.emit('launch:start', []); | ||
this.emitter.emit('launch:complete', []); | ||
this.emitter.emit('audit:start', []); | ||
this.emitter.emit('audit:complete', []); | ||
this.emitter.emit('test:start', []); | ||
this.emitter.emit('test:complete', []); | ||
await this.close(); | ||
return this.summary; | ||
} | ||
|
||
public async close(): Promise<void> { | ||
this.emitter.emit('close:start', []); | ||
this.emitter.emit('close:complete', []); | ||
} | ||
|
||
public on<T extends keyof CoreEventMap>( | ||
eventName: T, | ||
listener: EventListener<CoreEventMap, T>, | ||
): void { | ||
this.emitter.on(eventName as any, listener as any); | ||
} | ||
|
||
public off<T extends keyof CoreEventMap>( | ||
eventName: T, | ||
listener?: EventListener<CoreEventMap, T>, | ||
): void { | ||
this.emitter.off(eventName as any, listener as any); | ||
} | ||
} |
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 @@ | ||
export * from './core'; |
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,7 @@ | ||
{ | ||
"extends": "@acot/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"rootDir": "src" | ||
} | ||
} |