Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rewrite to TS and start using Jest #115

Merged
merged 8 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.vscode
node_modules
node_modules
lib
dist
coverage
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,36 @@ Save the result in a file by `-o, --output` flag:
asyncapi-converter streetlights.yml -o streetlights2.yml
```

### As a package
### In JS

```js
const fs = require('fs');
const { convert } = require('@asyncapi/converter')

try {
const asyncapi = fs.readFileSync('streetlights.yml', 'utf-8')
console.log(convert(asyncapi, '2.0.0', {
id: 'urn:com.asyncapi.streetlights'
}))
id: 'urn:com.asyncapi.streetlights'
}));
} catch (e) {
console.error(e);
}
```

### In TS

```ts
import { convert } from '@asyncapi/converter';
import type { ConvertVersion, ConvertOptions } from '@asyncapi/converter';

try {
const toVersion: ConvertVersion = '2.0.0';
const options: ConvertOptions = {
id: 'urn:com.asyncapi.streetlights'
};

const asyncapi = fs.readFileSync('streetlights.yml', 'utf-8')
console.log(convert(asyncapi, toVersion, options));
} catch (e) {
console.error(e)
}
Expand Down
26 changes: 26 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
coverageReporters: [
'json-summary',
'lcov',
'text'
],
preset: 'ts-jest',
// The root of your source code, typically /src
// `<rootDir>` is a token Jest substitutes
roots: ['<rootDir>'],

// Test spec file resolution pattern
// Matches parent folder `__tests__` and filename
// should contain `test` or `spec`.
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$',
// Module file extensions for importing
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testTimeout: 10000,
collectCoverageFrom: [
'src/**'
],
};

export default config;
109 changes: 0 additions & 109 deletions lib/helpers.js

This file was deleted.

Loading