feat: begin working on integration tests that will call actual onspring api sandbox

This commit is contained in:
StevanFreeborn
2023-02-13 21:02:00 -06:00
parent 757e773f9f
commit 5de13d6b5b
6 changed files with 64 additions and 3 deletions
+1 -1
View File
@@ -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",
+42
View File
@@ -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;
});
}
}
});
});
+13
View File
@@ -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",
+4 -1
View File
@@ -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",
+3
View File
@@ -0,0 +1,3 @@
import { OnspringClient } from './models/OnspringClient';
export { OnspringClient };
+1 -1
View File
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts", "tests/**/*.ts"]
"include": ["src/**/*.ts", "tests/**/*.ts", "integrationTests/**/*.ts"]
}