Migrate to mocha
This commit is contained in:
parent
7bde98e6a3
commit
4b839919fc
5 changed files with 77 additions and 43 deletions
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"extends": ["eslint:all", "prettier", "plugin:jest/all"],
|
||||
"plugins": ["prettier", "jest", "babel"],
|
||||
"extends": ["eslint:all", "prettier", "plugin:mocha/recommended"],
|
||||
"plugins": ["prettier", "mocha", "babel"],
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"strict": "off",
|
||||
|
||||
"mocha/no-mocha-arrows": "off",
|
||||
|
||||
"max-statements-per-line": "off",
|
||||
|
||||
"no-empty-function": "off",
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
"start": "node main.js -h 0.0.0.0 -c",
|
||||
"dev": "node --trace-warnings --max-old-space-size=4096 main.js -h 0.0.0.0",
|
||||
"dev:watch": "nodemon main.js -- -h 0.0.0.0",
|
||||
"test": "jest --no-cache --runInBand --verbose",
|
||||
"test:watch": "jest --no-cache --watch",
|
||||
"test": "mocha ./utils -b -t 50000 --recursive",
|
||||
"typecheck": "tsc",
|
||||
"lint": "eslint \"services/gunDB/**/*.js\"",
|
||||
"format": "prettier --write \"./**/*.js\"",
|
||||
|
|
@ -75,6 +74,7 @@
|
|||
"@types/gun": "^0.9.2",
|
||||
"@types/jsonwebtoken": "^8.3.7",
|
||||
"@types/lodash": "^4.14.168",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node-fetch": "^2.5.8",
|
||||
"@types/node-persist": "^3.1.1",
|
||||
"@types/ramda": "types/npm-ramda#dist",
|
||||
|
|
@ -85,6 +85,7 @@
|
|||
"eslint": "^6.6.0",
|
||||
"eslint-config-prettier": "^6.5.0",
|
||||
"eslint-plugin-babel": "^5.3.1",
|
||||
"eslint-plugin-mocha": "^9.0.0",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"expect": "^27.2.1",
|
||||
"lint-staged": "^10.2.2",
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
* @format
|
||||
*/
|
||||
// @ts-check
|
||||
/* eslint-disable jest/prefer-strict-equal */
|
||||
/* eslint-disable jest/no-test-callback */
|
||||
const Gun = require('./GunSmith')
|
||||
const words = require('random-words')
|
||||
const fs = require('fs')
|
||||
|
|
@ -57,7 +55,6 @@ const whenReady = () =>
|
|||
const delay = ms => new Promise(res => setTimeout(res, ms))
|
||||
|
||||
describe('gun smith', () => {
|
||||
// eslint-disable-next-line jest/no-hooks
|
||||
after(() => {
|
||||
Gun.kill()
|
||||
})
|
||||
|
|
@ -287,6 +284,8 @@ describe('gun smith', () => {
|
|||
await delay(500)
|
||||
|
||||
expect(called).toBe(false)
|
||||
|
||||
release()
|
||||
})
|
||||
|
||||
it('provides an user node with create(), auth() and leave()', async () => {
|
||||
|
|
@ -297,7 +296,6 @@ describe('gun smith', () => {
|
|||
expect(ack.err).toBeUndefined()
|
||||
|
||||
const { pub } = ack
|
||||
// eslint-disable-next-line jest/no-truthy-falsy
|
||||
expect(pub).toBeTruthy()
|
||||
expect(user.is?.pub).toEqual(pub)
|
||||
|
||||
|
|
@ -325,7 +323,6 @@ describe('gun smith', () => {
|
|||
user.auth(alias, pass, ack => res(ack))
|
||||
)
|
||||
const pub = authAck.sea?.pub
|
||||
// eslint-disable-next-line jest/no-truthy-falsy
|
||||
expect(pub).toBeTruthy()
|
||||
|
||||
Gun._reforge()
|
||||
|
|
@ -384,7 +381,48 @@ describe('gun smith', () => {
|
|||
release()
|
||||
})
|
||||
|
||||
// long tests below
|
||||
it('on()s and handles object>primitive>object transitions', done => {
|
||||
expect.assertions(3)
|
||||
whenReady().then(() => {
|
||||
const a = {
|
||||
one: 1
|
||||
}
|
||||
const b = 'two'
|
||||
const lastPut = {
|
||||
three: 3
|
||||
}
|
||||
const c = { ...a, ...lastPut }
|
||||
|
||||
const node = instance.get(words()).get(words())
|
||||
|
||||
let checked = 0
|
||||
|
||||
node.on(data => {
|
||||
checked++
|
||||
if (checked === 1) {
|
||||
expect(removeBuiltInGunProps(data)).toEqual(a)
|
||||
} else if (checked === 2) {
|
||||
expect(data).toEqual(b)
|
||||
} else if (checked === 3) {
|
||||
expect(removeBuiltInGunProps(data)).toEqual(c)
|
||||
done()
|
||||
release()
|
||||
}
|
||||
})
|
||||
|
||||
node.put(a)
|
||||
setTimeout(() => {
|
||||
node.put(b)
|
||||
}, 400)
|
||||
setTimeout(() => {
|
||||
node.put(c)
|
||||
}, 800)
|
||||
})
|
||||
})
|
||||
|
||||
// **************************************************************************
|
||||
// ** Long tests below
|
||||
// **************************************************************************
|
||||
|
||||
it('writes object items into sets and correctly populates item._.get with the newly created id', done => {
|
||||
expect.hasAssertions()
|
||||
|
|
@ -471,37 +509,4 @@ describe('gun smith', () => {
|
|||
}, 32000)
|
||||
})
|
||||
})
|
||||
|
||||
// eslint-disable-next-line jest/no-commented-out-tests
|
||||
// it('on()s and handles object>primitive>object transitions', async () => {
|
||||
// expect.assertions(3)
|
||||
// await whenReady()
|
||||
|
||||
// const a = {
|
||||
// one: 1
|
||||
// }
|
||||
// const b = 'two'
|
||||
// const c = {
|
||||
// three: 3
|
||||
// }
|
||||
// const d = { ...a, ...c }
|
||||
//
|
||||
// const node = instance.get(words()).get(words())
|
||||
//
|
||||
// let checked = 0
|
||||
//
|
||||
// node.on(data => logger.info(data))
|
||||
//
|
||||
// node.on(data => {
|
||||
// logger.info(data)
|
||||
// })
|
||||
//
|
||||
// node.put(a)
|
||||
// setTimeout(() => {
|
||||
// node.put(b)
|
||||
// }, 400)
|
||||
// setTimeout(() => {
|
||||
// node.put(c)
|
||||
// }, 800)
|
||||
// })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
const expect = require('expect')
|
||||
|
||||
const { asyncFilter } = require('./helpers')
|
||||
|
||||
|
|
|
|||
25
yarn.lock
25
yarn.lock
|
|
@ -525,6 +525,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d"
|
||||
integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==
|
||||
|
||||
"@types/mocha@^9.0.0":
|
||||
version "9.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297"
|
||||
integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA==
|
||||
|
||||
"@types/node-fetch@^2.5.8":
|
||||
version "2.5.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.8.tgz#e199c835d234c7eb0846f6618012e558544ee2fb"
|
||||
|
|
@ -2125,6 +2130,14 @@ eslint-plugin-babel@^5.3.1:
|
|||
dependencies:
|
||||
eslint-rule-composer "^0.3.0"
|
||||
|
||||
eslint-plugin-mocha@^9.0.0:
|
||||
version "9.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-9.0.0.tgz#b4457d066941eecb070dc06ed301c527d9c61b60"
|
||||
integrity sha512-d7knAcQj1jPCzZf3caeBIn3BnW6ikcvfz0kSqQpwPYcVGLoJV5sz0l0OJB2LR8I7dvTDbqq1oV6ylhSgzA10zg==
|
||||
dependencies:
|
||||
eslint-utils "^3.0.0"
|
||||
ramda "^0.27.1"
|
||||
|
||||
eslint-plugin-prettier@^3.1.4:
|
||||
version "3.1.4"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz#168ab43154e2ea57db992a2cd097c828171f75c2"
|
||||
|
|
@ -2152,11 +2165,23 @@ eslint-utils@^1.4.3:
|
|||
dependencies:
|
||||
eslint-visitor-keys "^1.1.0"
|
||||
|
||||
eslint-utils@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672"
|
||||
integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==
|
||||
dependencies:
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
|
||||
integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==
|
||||
|
||||
eslint-visitor-keys@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
|
||||
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
|
||||
|
||||
eslint@^6.6.0:
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.6.0.tgz#4a01a2fb48d32aacef5530ee9c5a78f11a8afd04"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue