Skip to content

Commit

Permalink
Support Node 6 and refactor tests to TypeScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Jun 4, 2018
1 parent 7953472 commit 0460929
Show file tree
Hide file tree
Showing 6 changed files with 392 additions and 505 deletions.
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "The bot that created the iPhone X.",
"main": "server/index.ts",
"scripts": {
"test": "tsc && ava",
"test": "ava",
"nyan": "ava --tap | tap-nyan",
"lint": "eslint . --ext .js,.ts,.tsx && tsc --noEmit && graphql-schema-linter server/schema.graphql",
"start": "node lib/index.js --production",
Expand All @@ -15,11 +15,11 @@
"author": "Ibrahim Ansari <ansari.ibrahim1@gmail.com>",
"license": "Apache-2.0",
"engines": {
"node": ">=8.5.0"
"node": ">=6.5.0"
},
"dependencies": {
"@material-ui/core": "^1.0.0-rc.1",
"@material-ui/icons": "^1.0.0-rc.0",
"@material-ui/core": "^1.2.0",
"@material-ui/icons": "^1.1.0",
"apollo-boost": "^0.1.4",
"eris": "^0.8.6",
"graphql": "^0.13.2",
Expand All @@ -36,12 +36,13 @@
"typescript": "^2.8.1"
},
"devDependencies": {
"@babel/plugin-syntax-typescript": "^7.0.0-beta.49",
"@types/mongodb": "^3.0.12",
"@types/next": "^2.4.7",
"@types/node": "^8.0.53",
"@types/react": "^16.0.36",
"@zeit/next-typescript": "^0.1.1",
"ava": "^1.0.0-beta.3",
"ava": "^1.0.0-beta.5.1",
"eslint": "^4.17.0",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
Expand All @@ -64,11 +65,15 @@
}
},
"ava": {
"files": [
"tests/**/*.js"
],
"sources": [
"bot/**/*.ts"
]
"files": ["tests/**/*.test.ts"],
"sources": ["server/**/*.ts"],
"require": ["ts-node/register"],
"babel": {
"testOptions": {
"presets": [["module:ava/stage-4", false]],
"plugins": ["@babel/plugin-syntax-typescript"]
},
"extensions": ["js", "ts"]
}
}
}
42 changes: 0 additions & 42 deletions tests/bot/commands/games.test.js

This file was deleted.

43 changes: 0 additions & 43 deletions tests/bot/imports/permissions.test.js

This file was deleted.

19 changes: 0 additions & 19 deletions tests/bot/imports/tools.test.js

This file was deleted.

40 changes: 40 additions & 0 deletions tests/bot/imports/tools.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import test from 'ava'
import {
getArguments, getIdFromMention, getDesc, getInsult // , getServerSettings
} from '../../../server/bot/imports/tools'
// import { MongoDBServer } from 'mongomem'
// import { MongoClient } from 'mongodb'

// Test getUser.

// test.before('start server', async t => { await MongoDBServer.start() }) // Start Mongo in memory
// test.after.always('cleanup', t => MongoDBServer.tearDown()) // Cleans up temporary file storage

test(
'getArguments returns proper arguments',
t => t.is(getArguments('/test command args'), 'command args')
)
test(
'getDesc returns proper arguments',
t => t.is(getDesc({ content: '/test command args' }), 'command args')
)
test('getIdFromMention returns a correct ID for users', t => {
t.is(getIdFromMention('<@!305053306835697674>'), '305053306835697674')
t.is(getIdFromMention('<@305053306835697674>'), '305053306835697674')
})
test('getIdFromMention returns a correct ID for channels', t => {
t.is(getIdFromMention('<#402423671551164418>'), '402423671551164418')
})
test('getIdFromMention returns a correct ID for roles', t => {
t.is(getIdFromMention('<@&412741172709163009>'), '412741172709163009')
})
test('getIdFromMention returns a correct ID for emoji', t => {
t.is(getIdFromMention('<:jry:402568226728312834>'), '402568226728312834')
})
test('getInsult works as expected', t => t.true([
'pathetic lifeform', 'ungrateful bastard', 'idiotic slimeball', 'worthless ass', 'dumb dolt'
].includes(getInsult())))
/* test('getServerSettings works on servers with no settings', async t => {
const db = await MongoClient.connect(await MongoDBServer.getConnectionString())
t.truthy(await getServerSettings(db.db('ivebot'), '402423671551164416'))
}) */
Loading

0 comments on commit 0460929

Please sign in to comment.