-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gourav <[email protected]>
- Loading branch information
1 parent
9e26f26
commit 76ecc39
Showing
2 changed files
with
58 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { test } from '@oclif/test'; | ||
import fs from 'fs'; | ||
import TestHelper from '../helpers'; | ||
import { expect } from 'chai'; | ||
|
||
const testHelper = new TestHelper(); | ||
const bundledFilePath = './asyncapi-bundled.yml'; | ||
|
||
describe('start preview', () => { | ||
beforeEach(() => { | ||
testHelper.createDummyContextFile(); | ||
}); | ||
|
||
afterEach(() => { | ||
testHelper.deleteDummyContextFile(); | ||
if (fs.existsSync(bundledFilePath)) { | ||
fs.unlinkSync(bundledFilePath); | ||
} | ||
}); | ||
|
||
test | ||
.stderr() | ||
.stdout() | ||
.command(['start:preview', './test/fixtures/specification.yml']) | ||
.it('bundles the AsyncAPI file and starts the studio', ({ stdout, stderr }) => { | ||
const output = stdout + stderr; | ||
expect(output).to.include('Starting Studio in preview mode...'); | ||
expect(output).to.include('Bundled file updated successfully.'); | ||
expect(fs.existsSync(bundledFilePath)).to.be.true; | ||
}); | ||
|
||
test | ||
.stderr() | ||
.stdout() | ||
.command(['start:preview', 'non-existing-context']) | ||
.it('throws error if context does not exist', ({ stdout, stderr }) => { | ||
const output = stdout + stderr; | ||
expect(output).to.include('ContextError: Context "non-existing-context" does not exist'); | ||
}); | ||
}); |