Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blue-tape -> node-tap #2223

Merged
merged 13 commits into from Aug 14, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -4,4 +4,4 @@ const rules = {
module.exports = {
extends: '@chatie',
rules,
}
}
16 changes: 10 additions & 6 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "wechaty",
"version": "0.65.6",
"version": "0.65.7",
"description": "Wechaty is a RPA SDK for Chatbot Makers.",
"main": "dist/src/mod.js",
"typings": "dist/src/mod.d.ts",
Expand All @@ -23,18 +23,19 @@
"doctor": "npm run check-node-version && ts-node bin/doctor",
"check-node-version": "check-node-version --node \">= 12\"",
"lint": "npm-run-all check-node-version lint:es lint:ts lint:sh lint:md",
"test:lint": "npm-run-all check-node-version lint:es lint:ts lint:sh lint:md",
"lint:es": "eslint --ignore-pattern node_modules/ --ignore-pattern fixtures/ \"{bin,examples,src,scripts,tests}/**/*.ts\"",
"lint:md": "markdownlint README.md",
"lint:ts": "tsc --noEmit",
"lint:sh": "bash -n bin/*.sh",
"puppet-install": "ts-node bin/puppet-install.ts",
"sloc": "sloc bin examples scripts src tests --details --format cli-table --keys total,source,comment && sloc bin examples scripts src tests",
"ts-node": "ts-node",
"test": "npm run lint && nyc npm run test:unit && npm run sloc",
"test": "npm run test:lint && nyc npm run test:unit && npm run sloc",
"test:pack": "bash -x scripts/npm-pack-testing.sh",
"test:shell": "shellcheck bin/*.sh scripts/*.sh",
"test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\"",
"test:debug": "blue-tape -r ts-node/register src/puppet-web/bridge.spec.ts",
"test:unit": "tap --node-arg=--require=ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\"",
"test:debug": "tap --node-arg=--require=ts-node/register src/puppet-web/bridge.spec.ts",
"typedoc": "bash scripts/typedoc.sh",
"io-client": "ts-node bin/io-client",
"demo": "ts-node examples/ding-dong-bot.ts",
Expand Down Expand Up @@ -104,14 +105,15 @@
"@chatie/eslint-config": "^0.12.4",
"@chatie/git-scripts": "^0.6.2",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.17.2",
"@chatie/tsconfig": "^0.16.2",
"@types/cuid": "^1.3.1",
"@types/dotenv": "^8.2.0",
"@types/glob": "^7.1.3",
"@types/open-graph": "^0.2.1",
"@types/promise-retry": "^1.1.3",
"@types/raven": "^2.5.3",
"@types/retry": "^0.12.0",
"@types/tap": "^15.0.5",
"@types/ws": "^7.4.4",
"apiai": "^4.0.3",
"check-node-version": "^4.1.0",
Expand All @@ -127,10 +129,12 @@
"qrcode-terminal": "^0.12.0",
"shx": "^0.3.3",
"sloc": "^0.2.1",
"tap": "^15.0.9",
"ts-node": "^10.1.0",
"tstest": "^0.4.10",
"typed-emitter": "^1.3.1",
"typedoc": "^1.0.0-dev.4 ",
"typescript": "^4.3",
"typescript": "^4.3.5",
"wechaty-puppet-mock": "^0.29.6"
},
"files_comment__whitelist_npm_publish": "http://stackoverflow.com/a/8617868/1123955",
Expand Down
16 changes: 8 additions & 8 deletions src/config.spec.ts
Expand Up @@ -19,23 +19,23 @@
*
*/

import test from 'blue-tape'
import { test } from 'tap'

import { config } from './config'
// import { Puppet } from './puppet'

test('important variables', async t => {
// t.true('puppet' in config, 'should exist `puppet` in Config')
t.true('apihost' in config, 'should exist `apihost` in Config')
t.true('token' in config, 'should exist `token` in Config')
void test('important variables', async t => {
// t.ok('puppet' in config, 'should exist `puppet` in Config')
t.ok('apihost' in config, 'should exist `apihost` in Config')
t.ok('token' in config, 'should exist `token` in Config')

// t.ok(config.default.DEFAULT_PUPPET , 'should export DEFAULT_PUPPET')
// t.ok(config.default.DEFAULT_PROFILE , 'should export DEFAULT_PROFILE')
t.ok(config.default.DEFAULT_PROTOCOL, 'should export DEFAULT_PROTOCOL')
t.ok(config.default.DEFAULT_APIHOST, 'should export DEFAULT_APIHOST')
})

test('validApiHost()', async t => {
void test('validApiHost()', async t => {
const OK_APIHOSTS = [
'api.chatie.io',
'chatie.io:8080',
Expand Down Expand Up @@ -73,7 +73,7 @@ test('validApiHost()', async t => {

// config.puppetInstance(mockPuppet)
// const instance = config.puppetInstance()
// t.deepEqual(instance, EXPECTED, 'should equal with initialized data')
// t.same(instance, EXPECTED, 'should equal with initialized data')

// config.puppetInstance(null)
// t.throws(() => {
Expand All @@ -83,7 +83,7 @@ test('validApiHost()', async t => {
// config.puppetInstance(bak)
// })

test('systemPuppetName ()', async t => {
void test('systemPuppetName ()', async t => {
const WECHATY_PUPPET_ORIG = process.env['WECHATY_PUPPET']

delete process.env['WECHATY_PUPPET']
Expand Down
16 changes: 8 additions & 8 deletions src/helper-functions/pure/loose-instance-of-class.spec.ts
Expand Up @@ -24,14 +24,14 @@ import { FileBox } from 'file-box'

import { looseInstanceOfClass } from './loose-instance-of-class'

test('looseInstanceOfClass: instanceof', async t => {
void test('looseInstanceOfClass: instanceof', async t => {
class Test {}
const looseInstanceOfTest = looseInstanceOfClass(Test)
const test = new Test()
t.true(looseInstanceOfTest(test), 'should be true for a real Test')
t.ok(looseInstanceOfTest(test), 'should be true for a real Test')
})

test('looseInstanceOfClass: constructor.name', async t => {
void test('looseInstanceOfClass: constructor.name', async t => {
class Test {}
const looseInstanceOfTest = looseInstanceOfClass(Test)

Expand All @@ -42,20 +42,20 @@ test('looseInstanceOfClass: constructor.name', async t => {
class Test {}
t.notEqual(OrigTest, Test, 'should has a new Test class different to the original Test class')
const f = new Test()
t.true(looseInstanceOfTest(f), 'should be true for the same name class like Test')
t.ok(looseInstanceOfTest(f), 'should be true for the same name class like Test')
}

})

test('looseInstanceOfClass: n/a', async t => {
void test('looseInstanceOfClass: n/a', async t => {
class Test {}
const looseInstanceOfTest = looseInstanceOfClass(Test)

const o = {}
t.false(looseInstanceOfTest(o), 'should be false for non-Test: {}')
})

test('looseInstanceOfClass for FileBox', async t => {
void test('looseInstanceOfClass for FileBox', async t => {
const f = FileBox.fromQRCode('test')
const looseInstanceOfFileBox = looseInstanceOfClass(FileBox as any as FileBox & { new (...args: any): FileBox })

Expand All @@ -64,8 +64,8 @@ test('looseInstanceOfClass for FileBox', async t => {
class FileBox {}
t.notEqual(OrigFileBox, FileBox, 'should be two different FileBox class')

t.true(f instanceof OrigFileBox, 'should be instanceof OrigFileBox')
t.ok(f instanceof OrigFileBox, 'should be instanceof OrigFileBox')
t.false(f instanceof FileBox, 'should not instanceof another FileBox class for one FileBox instance')
t.true(looseInstanceOfFileBox(f), 'should be true for looseInstanceOfFileBox because the class has the same name')
t.ok(looseInstanceOfFileBox(f), 'should be true for looseInstanceOfFileBox because the class has the same name')
}
})
4 changes: 2 additions & 2 deletions src/helper-functions/pure/timestamp-to-date.spec.ts
Expand Up @@ -26,15 +26,15 @@ import { timestampToDate } from './timestamp-to-date'
* in milliseconds: Sat Mar 03 1973 09:46:39 UTC
* in seconds: Wed Nov 16 5138 9:46:40 UTC
*/
test('timestampToDate() for dealing with seconds', async t => {
void test('timestampToDate() for dealing with seconds', async t => {
const SECONDS = 1e11 - 1
const EXPECTED_DATE_NOW = 'Wed, 16 Nov 5138 09:46:39 GMT'

const date = timestampToDate(SECONDS)
t.equal(date.toUTCString(), EXPECTED_DATE_NOW, 'should parse seconds to right date')
})

test('timestampToDate() for dealing with milliseconds', async t => {
void test('timestampToDate() for dealing with milliseconds', async t => {
const MILLISECONDS = 1e11 + 1
const EXPECTED_DATE_UTC = 'Sat, 03 Mar 1973 09:46:40 GMT'

Expand Down
12 changes: 6 additions & 6 deletions src/helper-functions/pure/try-wait.spec.ts
Expand Up @@ -18,13 +18,13 @@
* limitations under the License.
*
*/
import test from 'blue-tape'
import { test } from 'tap'
import sinon from 'sinon'

import { tryWait } from './try-wait'
import promiseRetry = require('promise-retry')

test('promiseRetry()', async t => {
void test('promiseRetry()', async t => {
const EXPECTED_RESOLVE = 'Okey'
const EXPECTED_REJECT = 'NotTheTime'

Expand Down Expand Up @@ -53,7 +53,7 @@ test('promiseRetry()', async t => {
).catch((e: any) => {
thenSpy(e)
})
t.true(thenSpy.withArgs(EXPECTED_REJECT).calledOnce, 'should got EXPECTED_REJECT when wait not enough')
t.ok(thenSpy.withArgs(EXPECTED_REJECT).calledOnce, 'should got EXPECTED_REJECT when wait not enough')

thenSpy.resetHistory()
const anotherDelay50 = delayedFactory(50)
Expand All @@ -69,10 +69,10 @@ test('promiseRetry()', async t => {
.then((r: string) => {
return thenSpy(r)
})
t.true(thenSpy.withArgs(EXPECTED_RESOLVE).calledOnce, 'should got EXPECTED_RESOLVE when wait enough')
t.ok(thenSpy.withArgs(EXPECTED_RESOLVE).calledOnce, 'should got EXPECTED_RESOLVE when wait enough')
})

test('retry()', async t => {
void test('retry()', async t => {
const EXPECTED_RESOLVE = 'Okey'
const EXPECTED_REJECT = 'NotTheTime'

Expand All @@ -98,5 +98,5 @@ test('retry()', async t => {
.then((r: string) => {
return thenSpy(r)
})
t.true(thenSpy.withArgs(EXPECTED_RESOLVE).calledOnce, 'should got EXPECTED_RESOLVE when wait enough')
t.ok(thenSpy.withArgs(EXPECTED_RESOLVE).calledOnce, 'should got EXPECTED_RESOLVE when wait enough')
})
12 changes: 6 additions & 6 deletions src/helper-functions/pure/xml.spec.ts
Expand Up @@ -29,15 +29,15 @@ import {
unifyEmoji,
} from './xml'

test('stripHtml()', async t => {
void test('stripHtml()', async t => {
const HTML_BEFORE_STRIP = 'Outer<html>Inner</html>'
const HTML_AFTER_STRIP = 'OuterInner'

const strippedHtml = stripHtml(HTML_BEFORE_STRIP)
t.is(strippedHtml, HTML_AFTER_STRIP, 'should strip html as expected')
})

test('unescapeHtml()', async t => {
void test('unescapeHtml()', async t => {
const HTML_BEFORE_UNESCAPE = '&apos;|&quot;|&gt;|&lt;|&amp;'
// eslint-disable-next-line
const HTML_AFTER_UNESCAPE = `'|"|>|<|&`
Expand All @@ -46,7 +46,7 @@ test('unescapeHtml()', async t => {
t.is(unescapedHtml, HTML_AFTER_UNESCAPE, 'should unescape html as expected')
})

test('plainText()', async t => {
void test('plainText()', async t => {
const PLAIN_BEFORE = '&amp;<html>&amp;</html>&amp;<img class="emoji emoji1f4a4" text="[流汗]_web" src="/zh_CN/htmledition/v2/images/spacer.gif" />'
const PLAIN_AFTER = '&&&[流汗]'

Expand All @@ -55,7 +55,7 @@ test('plainText()', async t => {

})

test('digestEmoji()', async t => {
void test('digestEmoji()', async t => {
const EMOJI_XML = [
'<img class="emoji emoji1f4a4" text="[流汗]_web" src="/zh_CN/htmledition/v2/images/spacer.gif" />',
'<img class="qqemoji qqemoji13" text="[呲牙]_web" src="/zh_CN/htmledition/v2/images/spacer.gif" />',
Expand All @@ -75,7 +75,7 @@ test('digestEmoji()', async t => {
}
})

test('unifyEmoji()', async t => {
void test('unifyEmoji()', async t => {
const ORIGNAL_XML_LIST: Array<[string[], string]> = [
[
[
Expand All @@ -94,7 +94,7 @@ test('unifyEmoji()', async t => {
})
})

test('stripEmoji()', async t => {
void test('stripEmoji()', async t => {
const EMOJI_STR = [
[
'ABC<img class="emoji emoji1f4a4" text="[流汗]_web" src="/zh_CN/htmledition/v2/images/spacer.gif" />DEF',
Expand Down
6 changes: 3 additions & 3 deletions src/io-peer/io-peer.spec.ts
Expand Up @@ -19,7 +19,7 @@
* limitations under the License.
*
*/
import test from 'blue-tape'
import { test } from 'tap'

import Peer, {
format,
Expand All @@ -31,7 +31,7 @@ import {
getPeer,
} from './io-peer'

test('getPeer()', async t => {
void test('getPeer()', async t => {
const EXPECTED_PORT = 8788
const server = getPeer({
serviceGrpcPort: EXPECTED_PORT,
Expand All @@ -48,7 +48,7 @@ test('getPeer()', async t => {
t.equal(port, EXPECTED_PORT, 'should get the right port')
})

test('exec()', async t => {
void test('exec()', async t => {
const EXPECTED_PORT = 8788
const server = getPeer({
serviceGrpcPort: EXPECTED_PORT,
Expand Down
1 change: 1 addition & 0 deletions src/io-peer/io-peer.ts
@@ -1,3 +1,4 @@
/// <reference path="json-rpc-peer.d.ts"/>
import Peer, {
JsonRpcPayload,
JsonRpcPayloadError,
Expand Down
4 changes: 2 additions & 2 deletions src/io.spec.ts
Expand Up @@ -19,12 +19,12 @@
* limitations under the License.
*
*/
import test from 'blue-tape'
import { test } from 'tap'

import { Io } from './io'
import { Wechaty } from './wechaty'

test('Io restart without problem', async t => {
void test('Io restart without problem', async t => {
const io = new Io({
// token must not contain any white spaces
servicePort : 8788,
Expand Down
14 changes: 7 additions & 7 deletions src/plugin.spec.ts
Expand Up @@ -19,7 +19,7 @@
* limitations under the License.
*
*/
import test from 'blue-tape'
import { test } from 'tap'
import sinon from 'sinon'

import { PuppetMock } from 'wechaty-puppet-mock'
Expand All @@ -29,7 +29,7 @@ import {
} from './wechaty'
import { WechatyPlugin } from './plugin'

test('Wechaty Plugin uninstaller should be called after wechaty.stop()', async t => {
void test('Wechaty Plugin uninstaller should be called after wechaty.stop()', async t => {
const spyPluginInstall = sinon.spy()
const spyPluginUninstall = sinon.spy()

Expand All @@ -42,15 +42,15 @@ test('Wechaty Plugin uninstaller should be called after wechaty.stop()', async t
}
}

t.true(spyPluginInstall.notCalled, 'should be clean for install spy')
t.true(spyPluginUninstall.notCalled, 'should be clean for uninstall spy')
t.ok(spyPluginInstall.notCalled, 'should be clean for install spy')
t.ok(spyPluginUninstall.notCalled, 'should be clean for uninstall spy')

bot.use(plugin)
t.true(spyPluginInstall.called, 'should called install spy after use()')
t.true(spyPluginUninstall.notCalled, 'should not call uninstall spy after use()')
t.ok(spyPluginInstall.called, 'should called install spy after use()')
t.ok(spyPluginUninstall.notCalled, 'should not call uninstall spy after use()')

await bot.start()
await bot.stop()

t.true(spyPluginUninstall.called, 'should called uninstall spy after stop()')
t.ok(spyPluginUninstall.called, 'should called uninstall spy after stop()')
})
4 changes: 2 additions & 2 deletions src/puppet-manager.spec.ts
Expand Up @@ -19,13 +19,13 @@
* limitations under the License.
*
*/
import test from 'blue-tape'
import { test } from 'tap'

import {
PuppetManager,
} from './puppet-manager'

test('resolve an unsupported puppet name', async t => {
void test('resolve an unsupported puppet name', async t => {
// try {
// await PuppetManager.resolve('fasdfsfasfsfdfs')
// t.fail('should reject')
Expand Down