-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(apidom-parser-adapter-asyncapi-yaml-2): run tests in ESM
- Loading branch information
Showing
16 changed files
with
165 additions
and
145 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/**/*.js | ||
/**/*.mjs | ||
/**/*.cjs | ||
/dist | ||
/es | ||
/cjs | ||
/types | ||
/config | ||
/.nyc_output | ||
/node_modules | ||
/**/*.js |
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,6 +1,7 @@ | ||
/src/**/*.mjs | ||
/src/**/*.cjs | ||
/test/**/*.mjs | ||
/dist | ||
/es | ||
/cjs | ||
/types | ||
/NOTICE | ||
/swagger-api-apidom-parser-adapter-asyncapi-yaml-2-*.tgz |
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,5 +1,6 @@ | ||
{ | ||
"recursive": true, | ||
"spec": "test/**/*.ts", | ||
"file": ["test/mocha-bootstrap.cjs"] | ||
"spec": "test/**/*.mjs", | ||
"file": ["test/mocha-bootstrap.mjs"], | ||
"ignore": ["test/perf/**/*.mjs"] | ||
} |
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
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
packages/apidom-parser-adapter-asyncapi-yaml-2/test/adapter.ts
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
15 changes: 0 additions & 15 deletions
15
packages/apidom-parser-adapter-asyncapi-yaml-2/test/mocha-bootstrap.cjs
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
packages/apidom-parser-adapter-asyncapi-yaml-2/test/mocha-bootstrap.ts
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,11 @@ | ||
import * as chai from 'chai'; | ||
import { jestSnapshotPlugin, addSerializer } from 'mocha-chai-jest-snapshot'; | ||
|
||
// @ts-ignore | ||
import * as jestApiDOMSerializer from '../../../scripts/jest-serializer-apidom'; | ||
// @ts-ignore | ||
import * as jestStringSerializer from '../../../scripts/jest-serializer-string'; | ||
|
||
chai.use(jestSnapshotPlugin()); | ||
addSerializer(jestApiDOMSerializer); | ||
addSerializer(jestStringSerializer); |
25 changes: 0 additions & 25 deletions
25
packages/apidom-parser-adapter-asyncapi-yaml-2/test/perf/index.cjs
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
packages/apidom-parser-adapter-asyncapi-yaml-2/test/perf/index.ts
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,24 @@ | ||
import Benchmark from 'benchmark'; | ||
import type { Event } from 'benchmark'; | ||
|
||
import lexicalAnalysisBench from './lexical-analysis'; | ||
import syntacticAnalysisBench from './syntactic-analysis'; | ||
import refractBench from './refract'; | ||
import parseBench from './parse'; | ||
|
||
const suite = new Benchmark.Suite(); | ||
|
||
suite | ||
.add(lexicalAnalysisBench) | ||
.add(syntacticAnalysisBench) | ||
.add(refractBench) | ||
.add(parseBench) | ||
// add listeners | ||
.on('cycle', function (event: Event) { | ||
console.info(String(event.target)); | ||
}) | ||
.on('complete', function () { | ||
console.info('\nAll benchmarks have completed'); | ||
}) | ||
// run | ||
.run(); |
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
37 changes: 0 additions & 37 deletions
37
packages/apidom-parser-adapter-asyncapi-yaml-2/test/perf/refract.cjs
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
packages/apidom-parser-adapter-asyncapi-yaml-2/test/perf/refract.ts
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,41 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import Benchmark from 'benchmark'; | ||
import type { Event } from 'benchmark'; | ||
import { ObjectElement, toValue } from '@swagger-api/apidom-core'; | ||
import { AsyncApi2Element } from '@swagger-api/apidom-ns-asyncapi-2'; | ||
|
||
import { parse } from '../../src/adapter'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const fixturePath = path.join(__dirname, 'fixtures/asyncapi.yaml'); | ||
const source = fs.readFileSync(fixturePath).toString(); | ||
const pojo = toValue((await parse(source)).result); | ||
|
||
const genericObjectElement = new ObjectElement(pojo); | ||
|
||
const options = { | ||
name: 'refract', | ||
minSamples: 600, | ||
expected: '350 ops/sec ±1.29% (679 runs sampled)', | ||
fn() { | ||
AsyncApi2Element.refract(genericObjectElement); | ||
}, | ||
}; | ||
|
||
export default options; | ||
|
||
// we're running as a script | ||
if (import.meta.url === `file://${process.argv[1]}`) { | ||
const bench = new Benchmark({ | ||
...options, | ||
onComplete(event: Event) { | ||
console.info(String(event.target)); | ||
}, | ||
onError(event: Event) { | ||
console.error(event); | ||
}, | ||
}); | ||
bench.run(); | ||
} |
Oops, something went wrong.