Skip to content

Commit

Permalink
Merge pull request #291 from Qminder/jest-tests
Browse files Browse the repository at this point in the history
Jest testing + major simplification changes
  • Loading branch information
Johannes Kadak authored Feb 11, 2021
2 parents 3ff7da6 + 7b301cd commit a024204
Show file tree
Hide file tree
Showing 34 changed files with 3,468 additions and 2,852 deletions.
26 changes: 1 addition & 25 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
{
"presets": ["es2017"],
"plugins": [
"transform-async-to-generator",
"check-es2015-constants",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoped-functions",
"transform-es2015-block-scoping",
"transform-es2015-classes",
"transform-es2015-computed-properties",
"transform-es2015-destructuring",
"transform-es2015-duplicate-keys",
"transform-es2015-for-of",
"transform-es2015-function-name",
"transform-es2015-literals",
"transform-es2015-modules-commonjs",
"transform-es2015-object-super",
"transform-es2015-parameters",
"transform-es2015-shorthand-properties",
"transform-es2015-spread",
"transform-es2015-sticky-regex",
"transform-es2015-template-literals",
"transform-es2015-typeof-symbol",
"transform-es2015-unicode-regex",
"transform-regenerator"
]
"presets": ["@babel/preset-env"],
}
6 changes: 5 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install Deps
run: yarn install --frozen-lockfile
- name: Build Library & Run Tests & Attempt to Package
- name: Run tests (browser)
run: yarn test
- name: Run tests (node)
run: yarn test-node
- name: Build the package
run: yarn pack
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ Network Trash Folder
Temporary Items
.apdisk

build-node
build-web
build-es6
node_modules
yarn-error.log
# IDEA GraphQL plugin config
graphql.config.json
.idea
.idea

build
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
node_modules
.github
docs
examples
manual
scripts
src
test
.babelrc
.gitignore
jest.config.js
tsconfig.json
*.log
*.lock
34 changes: 11 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[Documentation][doc] | [API Reference][api] | [Support][support]

The Qminder Javascript API library, supporting both Node.js (from 5.12.0) and browsers.
The Qminder Javascript API library, supporting both Node.js (from 10.0) and browsers.

### Setup

Expand All @@ -16,9 +16,7 @@ The Qminder Javascript API can be installed from npm:

### Usage

You can use Qminder API by importing it into your source code. The API uses the UMD module
definition, which means it should work with all Javascript module bundlers. For easier use, the
API library can just be included in the page, and will be accessible via the global Qminder object.
You can use Qminder API by importing it with the node.js module system.

// CommonJS / Node.js
const Qminder = require('qminder-api');
Expand All @@ -28,16 +26,6 @@ API library can just be included in the page, and will be accessible via the glo
import Qminder from 'qminder-api';
Qminder.setKey(...);

// AMD
define(function(require) {
const Qminder = require('qminder-api');
Qminder.setKey(...);
});

// Root object
// No including needed - just add the script tag to HTML.
Qminder.setKey(...);

After importing the Qminder API library, make sure to set the access token to connect to your
Qminder account. You can get the access token from your account's
[Integration settings][integration].
Expand Down Expand Up @@ -73,13 +61,16 @@ library. To include your local dev version of the Javascript API for the project

```bash
# 1. Build
npm run build
yarn build
yarn link
# 2. cd into the project you want to use API on
cd $PROJECT
# 3. install the local JS API folder, and keep track of its changes
npm install $JAVASCRIPT_API
yarn link qminder-api
# 4. Recompile the code
webpack
# ./build.sh
# webpack
# ... whatever build tool you use
# The project now uses your local development copy of the Javascript API.
# The JS API will be symlinked into your project, which means you can keep changing the
# JS API until your new feature works.
Expand All @@ -91,12 +82,9 @@ To contribute to the Qminder API, set up your development environment, then clon

To run various tasks on the code, use the following commands:

**Build the web version**: `npm run build-web`
**Build the node version**: `npm run build-node`
**Test the web version**: `npm run test-web` or `npm run test`
**Build web when code changes**: `npm run watch-web`
**Test web when code changes**: `npm run watch-tests`
**Compile documentation into the docs/ folder:**: `npm run docs`
**Build the library**: `yarn build`
**Test the library**: `yarn test` or `yarn test-node`
**Compile documentation into the docs/ folder:**: `yarn docs`

## Questions?

Expand Down
10 changes: 0 additions & 10 deletions index.html

This file was deleted.

12 changes: 0 additions & 12 deletions jasmine.json

This file was deleted.

10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: [
"jest-sinon",
"<rootDir>/test/unit/jestSetupFile.ts",
],
moduleFileExtensions: ['js', 'ts'],
transform: {},
};
100 changes: 0 additions & 100 deletions karma.conf.js

This file was deleted.

10 changes: 0 additions & 10 deletions manual/apidoc-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ code.

## Including in your project

The Node.js package includes three distributions:

- build-web: bundled, minified ES5 ready package, ready for inclusion via a `<script>` tag.
This distribution includes one script file that can be included directly on the web page.
- build-node: separated, minified Node.js package, including type declarations and sourcemaps.
This distribution will be used when you are creating a Node.js project.
- build-es6: separated, minified ES6+ package, using imports and async syntax, including type
declarations and sourcemaps. This distribution will be used if you use webpack or similar software
to package your code.

This package is set up in a way that you should be able to simply use the following code to include
Qminder API in your project:

Expand Down
Loading

0 comments on commit a024204

Please sign in to comment.