From 5de13d6b5bfc625432cdffbdb3f9a19e6aba0386 Mon Sep 17 00:00:00 2001 From: StevanFreeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 13 Feb 2023 21:02:00 -0600 Subject: [PATCH] feat: begin working on integration tests that will call actual onspring api sandbox --- .eslintrc.json | 2 +- integrationTests/getApps.spec.ts | 42 ++++++++++++++++++++++++++++++++ package-lock.json | 13 ++++++++++ package.json | 5 +++- src/index.ts | 3 +++ tsconfig.eslint.json | 2 +- 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 integrationTests/getApps.spec.ts diff --git a/.eslintrc.json b/.eslintrc.json index a64089a..7f15e2c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,7 +13,7 @@ ], "overrides": [ { - "files": ["tests/**/*.spec.ts"], + "files": ["tests/**/*.spec.ts", "integrationTests/**/*.spec.ts"], "rules": { "@typescript-eslint/no-unused-expressions": "off", "@typescript-eslint/consistent-type-assertions": "off", diff --git a/integrationTests/getApps.spec.ts b/integrationTests/getApps.spec.ts new file mode 100644 index 0000000..2f987c9 --- /dev/null +++ b/integrationTests/getApps.spec.ts @@ -0,0 +1,42 @@ +import { OnspringClient } from '../src/index'; +import { expect } from 'chai'; +import * as dotenv from 'dotenv'; +import path from 'path'; +const envPath = path.resolve(__dirname, '.env'); +dotenv.config({ path: envPath }); + +describe('getApps', function () { + const baseURL = 'https://api.onspring.com'; + let apiKey; + + before(function () { + apiKey = process.env.SANDBOX_API_KEY; + }); + + it('should return a list of apps', async function () { + const client = new OnspringClient(baseURL, apiKey); + const response = await client.getApps(); + + expect(response.statusCode).to.equal(200); + expect(response.isSuccessful).to.be.true; + expect(response.message).to.equal(''); + expect(response.data).to.not.be.null; + + if (response.data != null) { + expect(response.data.pageNumber).to.not.be.null; + expect(response.data.pageSize).to.not.be.null; + expect(response.data.totalPages).to.not.be.null; + expect(response.data.totalRecords).to.not.be.null; + expect(response.data.items).to.not.be.null; + + if (response.data.items != null) { + expect(response.data.items.length).to.be.greaterThan(0); + response.data.items.forEach((item) => { + expect(item.id).to.not.be.null; + expect(item.name).to.not.be.null; + expect(item.href).to.not.be.null; + }); + } + } + }); +}); diff --git a/package-lock.json b/package-lock.json index 2b757aa..f001896 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@typescript-eslint/eslint-plugin": "^5.50.0", "@typescript-eslint/parser": "^5.50.0", "chai": "^4.3.7", + "dotenv": "^16.0.3", "eslint": "^8.33.0", "eslint-config-prettier": "^8.6.0", "eslint-config-standard-with-typescript": "^34.0.0", @@ -35,6 +36,9 @@ "sinon": "^15.0.1", "ts-node": "^10.9.1", "typescript": "^4.9.5" + }, + "engines": { + "node": ">=18.14.0" } }, "node_modules/@ampproject/remapping": { @@ -1896,6 +1900,15 @@ "node": ">=6.0.0" } }, + "node_modules/dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.284", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", diff --git a/package.json b/package.json index 55a5e6c..4aa7243 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,10 @@ "format-staged": "pretty-quick --staged", "format": "pretty-quick", "build": "npm run lint-fix && npm run tests && npm run format && npm run clean && tsc --project tsconfig.cjs.json & tsc --project tsconfig.esm.json", - "tests": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", "test": "mocha -r ts-node/register", + "tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", + "tests:integration": "mocha -R progress -r ts-node/register ./integrationTests/**/*.spec.ts", + "tests": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts ./integrationTests/**/*.spec.ts", "test-coverage": "nyc npm run tests", "prepare": "husky install" }, @@ -53,6 +55,7 @@ "@typescript-eslint/eslint-plugin": "^5.50.0", "@typescript-eslint/parser": "^5.50.0", "chai": "^4.3.7", + "dotenv": "^16.0.3", "eslint": "^8.33.0", "eslint-config-prettier": "^8.6.0", "eslint-config-standard-with-typescript": "^34.0.0", diff --git a/src/index.ts b/src/index.ts index e69de29..10f6039 100644 --- a/src/index.ts +++ b/src/index.ts @@ -0,0 +1,3 @@ +import { OnspringClient } from './models/OnspringClient'; + +export { OnspringClient }; diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index d1afefe..a41d7fb 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "include": ["src/**/*.ts", "tests/**/*.ts"] + "include": ["src/**/*.ts", "tests/**/*.ts", "integrationTests/**/*.ts"] }