Skip to content

Commit

Permalink
update config
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jan 10, 2024
1 parent 165ef88 commit 7684893
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test": "npm run test:unit && npm run test:browser",
"test:unit": "cross-env CI=true jest --coverage --testPathIgnorePatterns=test/browser/*",
"test:browser": "npm run build:browser && cross-env CI=true jest -- ./test/browser/*",
"test:browser_new": "npm run build:browser_new && cross-env CI=true jest -- ./test/browser_new/*",
"test:browser_new": "cross-env CI=true jest -- ./test/browser_new/*",
"lint": "eslint --max-warnings 0 --config .eslintrc .",
"lint:fix": "eslint --max-warnings 0 --config .eslintrc . --fix",
"generate:readme:toc": "markdown-toc -i \"README.md\"",
Expand Down
9 changes: 7 additions & 2 deletions test/browser_new/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ describe('Test browser Parser in the node env', function() {

console.info('start server');
server = http.createServer((req, res) => {
res.writeHead(200, { 'content-type': 'text/html' });
if (req.url === '/') {
res.writeHead(200, { 'content-type': 'text/html' });
return fs.createReadStream(htmlPath).pipe(res);
} else if (req.url === '/parser.js') {
res.writeHead(200, { 'content-type': 'text/html' });
return fs.createReadStream(parserScript).pipe(res);
} else if (req.url === '/asyncapi.json') {
res.writeHead(200, { 'content-type': 'application/json' });
res.write(JSON.stringify({ asyncapi: '2.0.0', info: { title: 'My API', version: '1.0.0' }, channels: { '/test/tester': { subscribe: { operationId: 'subscribeOperation', message: { } } } } }));
res.end();
}
});
server.listen(8080);
Expand All @@ -40,7 +45,7 @@ describe('Test browser Parser in the node env', function() {

console.info('navigating to localhost');
await page.goto('http://localhost:8080', { waitUntil: 'networkidle0' });
});
}, 5000);

afterAll(async function() {
await browser.close();
Expand Down
5 changes: 2 additions & 3 deletions test/browser_new/sample-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
async function parse() {
try {
const parser = new window.AsyncAPIParser.Parser();
const spec = '{ "asyncapi": "2.0.0", "info": { "title": "My API", "version": "1.0.0" }, "channels": { "/test/tester": { "subscribe": { "operationId": "subscribeOperation", "message": { } } } } }';
const { document: parsedDocument, diagnostics } = await parser.parse(spec);

const result = window.AsyncAPIParser.fromURL(parser, 'http://localhost:8080/asyncapi.json');
const {document: parsedDocument, diagnostics} = await result.parse();
document.getElementById('content').innerHTML = parsedDocument.version();
document.getElementById('diagnostics').innerHTML = String(diagnostics.length);
} catch (error) {
Expand Down

0 comments on commit 7684893

Please sign in to comment.