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

Bug/missing tests #13

Merged
merged 13 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 2 additions & 1 deletion .depcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ ignores: [
'@swc-node/register',
'prettier-plugin-organize-imports',
'rimraf',
'typescript'
'typescript',
'@digicatapult/dtdl-parser'
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
]
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:

tests:
name: Run tests
strategy:
matrix:
command: ['test', test:integration]
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -73,7 +76,7 @@ jobs:
- name: Install Packages
run: npm ci
- name: Run tests
run: npm run test
run: npm run ${{ matrix.command }}

check-version:
name: "Check version"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
strategy:
fail-fast: false
matrix:
command: ['test']
command: ['test', test:integration]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -89,4 +89,4 @@ jobs:
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
bin
obj
build/
build/
*.tgz
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# dtdl-parser library

A library for parsing and validating (DTDL)[https://learn.microsoft.com/en-us/azure/digital-twins/concepts-models] ontologies.
A library for parsing and validating [DTDL](https://learn.microsoft.com/en-us/azure/digital-twins/concepts-models) ontologies.

## Installation / Adding to the Package.json

`@digicatapult/dtdl-parser` are available as an [npm package](https://www.npmjs.com/package/@digicatapult/dtdl-parser). In order to use your local version in the project please use `npm link` more on it -> [here](https://docs.npmjs.com/cli/v10/commands/npm-link) and below in this document

```sh
// with npm
npm install @digicatapult/ui-component-library
npm install @digicatapult/dtdl-parser
```

## Basic Usage

Install dependencies

```javascript
import { parseDirectories, validateDirectories, getInterop } from "dtdl-parser"
import { parseDirectories, validateDirectories, getInterop } from "@digicatapult/dtdl-parser"


const parser = await getInterop()
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digicatapult/dtdl-parser",
"version": "0.0.25",
"version": "0.0.26",
"description": "JS tool to parse DTDL defined Ontologies",
"main": "build/index.js",
"type": "module",
Expand All @@ -14,13 +14,16 @@
],
"scripts": {
"test": "NODE_ENV=test ./node_modules/.bin/mocha --config ./test/mocharc.json ./src/**/*.test.ts",
"test:integration": "npm run build:package && NODE_ENV=test ./node_modules/.bin/mocha --config ./test/mocharc.json ./test/**/*.test.ts && npm run clean:package",
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
"build": "npm run build:ts && npm run interop:build && npm run build:declarations",
"build:declarations": "tsc --emitDeclarationOnly",
"build:package": "npm pack && npm install -g digicatapult-dtdl-parser-*.tgz",
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
"interop:debug": "dotnet build interop",
"interop:build": "dotnet build src/interop --configuration Release",
"build:ts": "swc ./src -d ./build --strip-leading-paths",
"check": "tsc --noEmit",
"clean": "rimraf -rf ./build",
"clean:package": "rimraf *.tgz && npm uninstall @digicatapult/dtdl-parser",
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
"lint": "eslint .",
"depcheck": "depcheck"
},
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import path from 'path'
import { parseDirectories, searchForJsonFiles, validateDirectories } from '../index'
import { Parser } from '../interop'

const fixturesFilepath = path.resolve('src/__tests__/fixtures')
export const fixturesFilepath = path.resolve('src/__tests__/fixtures')

const exampleModel = {
export const exampleModel = {
syedhasandigi marked this conversation as resolved.
Show resolved Hide resolved
'dtmi:com:example:base;1': {
languageMajorVersion: 3,
Id: 'dtmi:com:example:base;1',
Expand Down
13 changes: 13 additions & 0 deletions test/integration/package.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getInterop, parseDirectories } from '@digicatapult/dtdl-parser'
mattdean-digicatapult marked this conversation as resolved.
Show resolved Hide resolved
import { expect } from 'chai'
import { exampleModel, fixturesFilepath } from '../../src/__tests__/index.test'

describe('integration test on build and package integrity', () => {
describe('parser to function as expected', async () => {
const parser = await getInterop()
it('parser to function as expected', () => {
const model = parseDirectories(fixturesFilepath, parser)
expect(model).to.equal(exampleModel)
})
})
})
syedhasandigi marked this conversation as resolved.
Show resolved Hide resolved