forked from mongoosejs/sample-apps
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from stargate/vkarpov15/discord-bot-tests
Automated tests for discord bot sample app
- Loading branch information
Showing
20 changed files
with
198 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
stargate_version=v2.1.0-ALPHA-6 | ||
json_api_version=v1.0.0-ALPHA-12 | ||
stargate_version=v2.1.0-BETA-2 | ||
json_api_version=v1.0.0-BETA-3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
JSON_API_URL=http://127.0.0.1:8181/v1/discordbot_test | ||
JSON_API_AUTH_USERNAME=cassandra | ||
JSON_API_AUTH_PASSWORD=cassandra | ||
JSON_API_AUTH_URL=http://localhost:8081/v1/auth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const Bot = require('../models/bot'); | ||
const assert = require('assert'); | ||
const { describe, it } = require('mocha'); | ||
const countdocuments = require('../commands/countdocuments'); | ||
const sinon = require('sinon'); | ||
|
||
describe('countdocuments', function() { | ||
it('returns the number of bot documents', async function() { | ||
await Bot.deleteMany({}); | ||
await Bot.create({ name: 'test' }); | ||
|
||
const interaction = { | ||
reply: sinon.stub() | ||
}; | ||
await countdocuments.execute(interaction); | ||
assert.ok(interaction.reply.calledOnce); | ||
assert.deepEqual(interaction.reply.getCalls()[0].args, [1]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const Bot = require('../models/bot'); | ||
const assert = require('assert'); | ||
const { describe, it } = require('mocha'); | ||
const createdocument = require('../commands/createdocument'); | ||
const sinon = require('sinon'); | ||
|
||
describe('createdocument', function() { | ||
it('inserts a new document', async function() { | ||
await Bot.deleteMany({}); | ||
|
||
const interaction = { | ||
reply: sinon.stub() | ||
}; | ||
await createdocument.execute(interaction); | ||
assert.ok(interaction.reply.calledOnce); | ||
assert.deepEqual(interaction.reply.getCalls()[0].args, ['done!']); | ||
|
||
const docs = await Bot.find(); | ||
assert.equal(docs.length, 1); | ||
assert.equal(docs[0].name, 'I am a document'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const { describe, it } = require('mocha'); | ||
const ping = require('../commands/ping'); | ||
const sinon = require('sinon'); | ||
|
||
describe('ping', function() { | ||
it('replies with "Pong!"', async function() { | ||
const interaction = { | ||
reply: sinon.stub() | ||
}; | ||
await ping.execute(interaction); | ||
assert.ok(interaction.reply.calledOnce); | ||
assert.deepEqual(interaction.reply.getCalls()[0].args, ['Pong!']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
require('dotenv').config({ path: `${__dirname}/../.env.test` }); | ||
|
||
const Bot = require('../models/bot'); | ||
const { before } = require('mocha'); | ||
const mongoose = require('../mongoose'); | ||
|
||
const uri = process.env.JSON_API_URL; | ||
const jsonApiConnectOptions = { | ||
username: process.env.JSON_API_AUTH_USERNAME, | ||
password: process.env.JSON_API_AUTH_PASSWORD, | ||
authUrl: process.env.JSON_API_AUTH_URL | ||
}; | ||
|
||
before(async function() { | ||
console.log('Connecting to', uri); | ||
await mongoose.connect(uri, jsonApiConnectOptions); | ||
await Bot.db.dropCollection('bots').catch(() => {}); | ||
await Bot.createCollection(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#Fill the Local JSON API related details only when NODE_ENV is set to 'jsonapi' | ||
#Local JSON API URL for example: http://127.0.0.1:8181/v1/ecommerce_test where 'ecommerce_test' is the keyspace name | ||
JSON_API_URL=http://127.0.0.1:8181/v1/ecommerce_test | ||
#Auth URL for example: http://127.0.0.1:8081/v1/auth | ||
JSON_API_AUTH_URL=http://127.0.0.1:8081/v1/auth | ||
#Auth username and password | ||
JSON_API_AUTH_USERNAME=cassandra | ||
JSON_API_AUTH_PASSWORD=cassandra | ||
|
||
#Fill in Stripe related details if you want to see Stripe integration. | ||
#Otherwise the sample app will bypass Stripe. | ||
STRIPE_SECRET_KEY=test-key | ||
STRIPE_SUCCESS_URL=http://127.0.0.1:8888/order-confirmation | ||
STRIPE_CANCEL_URL=http://127.0.0.1:8888/cart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
extends: [ | ||
'@masteringjs' | ||
], | ||
parserOptions: { | ||
ecmaVersion: 2020 | ||
}, | ||
env: { | ||
node: true, | ||
es6: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
env: { | ||
browser: true | ||
}, | ||
globals: { | ||
Vue: true, | ||
VueRouter: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (html, css) => { | ||
appendCSS(css); | ||
return { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.