Skip to content

Commit

Permalink
add tests for promise state
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Dec 2, 2021
1 parent 6c6a963 commit bae0953
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/eslint.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Eslint
on:
push:

jobs:
check_eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: |
sudo npm install -g eslint
- run: eslint index.js --ext .js,.jsx,.ts,.tsx
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: 17
- run: |
npm install
- run: |
npm run-script test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
yarn.lock
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
"description": "A fake implementaion of Q",
"keywords": [
],
"scripts": {
"test": "mocha"
},
"main": "index.js",
"author": "Mathew Heard",
"license": "ISC",
"dependencies": {
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^8.2.1"
},
"repository": "splitice/q-lite"
}
20 changes: 20 additions & 0 deletions test/state-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const {expect} = require('chai')
const Q = require('../index')

describe('Q state tests', function(){
it('Pending Q promise should be pending', async() => {
const qp = Q.defer()
expect(Q.isPending(qp.promise)).be.true
})
it('Resolved Q promise should be resolved', async() => {
const qp = Q.defer()
qp.resolve(true)
expect(Q.isFulfilled(qp.promise)).be.true
})
it('Rejected Q promise should be rejected', async() => {
const qp = Q.defer()
qp.promise.catch(() => {})
qp.reject('a')
expect(Q.isRejected(qp.promise)).be.true
})
})

0 comments on commit bae0953

Please sign in to comment.