Add cloud function integration tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -64,3 +64,4 @@ node_modules/
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
./src/api/firebase.js
|
724
functions/package-lock.json
generated
724
functions/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,8 @@
|
||||
"shell": "firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
"logs": "firebase functions:log"
|
||||
"logs": "firebase functions:log",
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"engines": {
|
||||
"node": "16"
|
||||
@ -14,9 +15,12 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"axios": "^1.3.3",
|
||||
"chai": "^4.3.7",
|
||||
"chai-http": "^4.3.0",
|
||||
"firebase": "^9.17.1",
|
||||
"firebase-admin": "^11.5.0",
|
||||
"firebase-functions": "^4.2.0",
|
||||
"mocha": "^10.2.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
29
functions/test/index.test.js
Normal file
29
functions/test/index.test.js
Normal file
@ -0,0 +1,29 @@
|
||||
const chai = require('chai');
|
||||
const chaiHttp = require('chai-http');
|
||||
|
||||
chai.use(chaiHttp);
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('Firebase cloud function tests', function() {
|
||||
this.timeout(100000);
|
||||
it('Test getting live train data', async() => {
|
||||
const result = await chai.request('https://us-central1-irishrailtracker.cloudfunctions.net')
|
||||
.get('/getLiveTrainData')
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(result.body.data).to.be.an('Array');
|
||||
expect(result.body.data[0]).haveOwnProperty('TrainStatus');
|
||||
expect(result.body.data[0]).haveOwnProperty('PublicMessage');
|
||||
expect(result.body.data[0]).haveOwnProperty('TrainLatitude');
|
||||
expect(result.body.data[0]).haveOwnProperty('Direction');
|
||||
expect(result.body.data[0]).haveOwnProperty('TrainLongitude');
|
||||
expect(result.body.data[0]).haveOwnProperty('TrainCode');
|
||||
expect(result.body.data[0]).haveOwnProperty('TrainDate');
|
||||
}),
|
||||
|
||||
this.timeout(100000);
|
||||
it('Test updating the database with live train data', async() => {
|
||||
const result = await chai.request('https://us-central1-irishrailtracker.cloudfunctions.net')
|
||||
.get('/postLiveTrainData')
|
||||
expect(result.statusCode).to.equal(200);
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user