Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
k-grube committed Apr 5, 2022
1 parent 0395d6f commit f4ac6ad
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 19 deletions.
154 changes: 154 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# Generated files
.idea/


# CMake
cmake-build-*/

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# secrets, scratch files, temp
test/.env
scratch/
temp/
docs/
.github/
generator/
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "connectwise-rest",
"version": "1.0.0",
"version": "1.0.1",
"description": "A nodejs module for interacting with the ConnectWise Manage and Automate REST APIs.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -77,6 +77,6 @@
"typescript": "^4.6.2"
},
"engines": {
"node": ">=16"
"node": ">=12"
}
}
1 change: 0 additions & 1 deletion src/BaseAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ function getPage(
page = 1,
pageSize = 1000,
): Promise<unknown[]> {
console.log('paginate getPage', page)
// Javascript Function.length returns number of non-default values
// the method args will always be greater than the api method args
// due to this, if params is not passed in, even as an empty object,
Expand Down
33 changes: 31 additions & 2 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { ManageAPI, AutomateAPI, utils } from '../dist/index'
import assert from 'assert'
import { describe, it } from 'mocha'
import type { components } from '../src/ManageTypes'
import { isArrayOfPromises, PromiseArray } from './test-utils'
import { isPromise } from './test-utils'
import { LabTechModelsComputer } from '../src/Automate/ComputersAPI'
import { CommunicationType } from '../src/Manage/CompanyAPI'
type Ticket = components['schemas']['Ticket']

dotenv.config({ path: path.join(__dirname, '.env') })
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('Automate', () => {
assert(computer.ComputerName)
done()
})
.catch((error: any) => done(error))
.catch((error) => done(error))
})
})
})
Expand Down Expand Up @@ -261,6 +261,35 @@ describe('Manage', () => {
})
})
})

describe('pagination', () => {
it('should return an array of CommunicationTypes', (done) => {
cwm
.paginate(cwm.CompanyAPI.getCompanyCommunicationTypes, { pageSize: 2, startPage: 1 }, {})
.then((results) => {
assert(Array.isArray(results))
assert(results.length > 0)
const firstType = <CommunicationType>results.pop()
assert(firstType.id)
assert(firstType.description)
assert(firstType._info)
done()
})
.catch((err) => done(err))
})

it('should return the same number of items', (done) => {
cwm
.paginate(cwm.CompanyAPI.getCompanyCommunicationTypes, { pageSize: 2, startPage: 1 }, {})
.then((pagedResults) => {
return cwm.CompanyAPI.getCompanyCommunicationTypes().then((unPagedResults) => {
assert(unPagedResults.length === pagedResults.length)
done()
})
})
.catch((err) => done(err))
})
})
})

describe('utils', () => {
Expand Down

0 comments on commit f4ac6ad

Please sign in to comment.