diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efbc17e..d894976 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,6 +56,9 @@ jobs: tests: name: Run tests + strategy: + matrix: + command: ['test', 'test:integration'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -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" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c3a818..7c18a19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -89,4 +89,4 @@ jobs: id: get_version uses: digicatapult/check-version@v1 with: - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 8b8c35d..5c8518a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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 @@ -8,7 +8,7 @@ A library for parsing and validating (DTDL)[https://learn.microsoft.com/en-us/az ```sh // with npm -npm install @digicatapult/ui-component-library +npm install @digicatapult/dtdl-parser ``` ## Basic Usage @@ -16,7 +16,7 @@ npm install @digicatapult/ui-component-library Install dependencies ```javascript -import { parseDirectories, validateDirectories, getInterop } from "dtdl-parser" +import { parseDirectories, validateDirectories, getInterop } from "@digicatapult/dtdl-parser" const parser = await getInterop() diff --git a/eslint.config.mjs b/eslint.config.mjs index 4851180..09466ea 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -47,6 +47,6 @@ export default [ }, }, { - ignores: ['build/', 'node_modules/', 'interop/'], + ignores: ['build/', 'node_modules/', 'src/interop/'], }, ] diff --git a/package-lock.json b/package-lock.json index 82435a6..0dcb788 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@digicatapult/dtdl-parser", - "version": "0.0.26", + "version": "0.0.27", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@digicatapult/dtdl-parser", - "version": "0.0.26", + "version": "0.0.27", "license": "Apache-2.0", "devDependencies": { "@eslint/eslintrc": "^3.1.0", diff --git a/package.json b/package.json index 9cccbd4..5324973 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digicatapult/dtdl-parser", - "version": "0.0.26", + "version": "0.0.27", "description": "JS tool to parse DTDL defined Ontologies", "main": "build/index.js", "type": "module", @@ -14,6 +14,7 @@ ], "scripts": { "test": "NODE_ENV=test ./node_modules/.bin/mocha --config ./test/mocharc.json ./src/**/*.test.ts", + "test:integration": "npm run build && NODE_ENV=test ./node_modules/.bin/mocha --config ./test/integration/mocharc.json ./test/**/*.test.js", "build": "npm run build:ts && npm run interop:build && npm run build:declarations", "build:declarations": "tsc --emitDeclarationOnly", "interop:debug": "dotnet build interop", diff --git a/test/integration/mocharc.json b/test/integration/mocharc.json new file mode 100644 index 0000000..6bf91c5 --- /dev/null +++ b/test/integration/mocharc.json @@ -0,0 +1,4 @@ +{ + "timeout": 5000, + "exit": true +} diff --git a/test/integration/package.test.js b/test/integration/package.test.js new file mode 100644 index 0000000..48fcd13 --- /dev/null +++ b/test/integration/package.test.js @@ -0,0 +1,63 @@ +import { expect } from 'chai' +import { describe, it } from 'mocha' +import path from 'node:path' +import { getInterop, parseDirectories } from '../../build/index.js' + +const fixturesFilepath = path.resolve('dtdl/simple') + +const emptyEntityProperties = { + SupplementalTypes: [], + SupplementalProperties: {}, + UndefinedTypes: [], + UndefinedProperties: {}, + description: {}, + languageMajorVersion: 2, + displayName: {}, + ChildOf: null, + DefinedIn: null, +} +const emptyInterfaceProperties = { + contents: {}, + commands: {}, + components: {}, + properties: {}, + relationships: {}, + telemetries: {}, + extendedBy: [], + extends: [], + schemas: [], + comment: null, +} + +const exampleModel = { + 'dtmi:com:example:base;1': { + ...emptyEntityProperties, + ...emptyInterfaceProperties, + languageMajorVersion: 3, + Id: 'dtmi:com:example:base;1', + ChildOf: 'dtmi:com:example;1', + DefinedIn: 'dtmi:com:example;1', + EntityKind: 'Interface', + ClassId: 'dtmi:dtdl:class:Interface;3', + extendedBy: ['dtmi:com:example;1'], + }, + 'dtmi:com:example;1': { + ...emptyEntityProperties, + ...emptyInterfaceProperties, + languageMajorVersion: 3, + Id: 'dtmi:com:example;1', + EntityKind: 'Interface', + ClassId: 'dtmi:dtdl:class:Interface;3', + extends: ['dtmi:com:example:base;1'], + }, +} + +describe('integration test on build and package integrity', () => { + describe('parser to function as expected', () => { + it('parser to function as expected', async () => { + const parser = await getInterop() + const model = parseDirectories(fixturesFilepath, parser) + expect(model).to.deep.equal(exampleModel) + }) + }) +})