* chore(package): update jasmine to version 3.0.0 Closes #4547 * Fixes failing tests for jasmine 3.0 Starting 3.0, done(something) will fail * Update tests so they dont leverage var, but let and const With jasmine 3.0, the randomization engine was making the test fails because of the scope of `var` * Remove randomizer * Use same adapter for PG tests, drop table to ensure the tests dont side effect
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
const UserController = require('../src/Controllers/UserController').UserController;
|
|
const emailAdapter = require('./MockEmailAdapter')
|
|
const AppCache = require('../src/cache').AppCache;
|
|
|
|
describe('UserController', () => {
|
|
const user = {
|
|
_email_verify_token: 'testToken',
|
|
username: 'testUser',
|
|
email: 'test@example.com'
|
|
}
|
|
|
|
describe('sendVerificationEmail', () => {
|
|
describe('parseFrameURL not provided', () => {
|
|
it('uses publicServerURL', (done) => {
|
|
|
|
AppCache.put(defaultConfiguration.appId, Object.assign({}, defaultConfiguration, {
|
|
publicServerURL: 'http://www.example.com',
|
|
customPages: {
|
|
parseFrameURL: undefined
|
|
}
|
|
}))
|
|
|
|
emailAdapter.sendVerificationEmail = (options) => {
|
|
expect(options.link).toEqual('http://www.example.com/apps/test/verify_email?token=testToken&username=testUser')
|
|
done()
|
|
}
|
|
|
|
const userController = new UserController(emailAdapter, 'test', {
|
|
verifyUserEmails: true
|
|
})
|
|
|
|
userController.sendVerificationEmail(user)
|
|
})
|
|
})
|
|
|
|
describe('parseFrameURL provided', () => {
|
|
it('uses parseFrameURL and includes the destination in the link parameter', (done) => {
|
|
|
|
AppCache.put(defaultConfiguration.appId, Object.assign({}, defaultConfiguration, {
|
|
publicServerURL: 'http://www.example.com',
|
|
customPages: {
|
|
parseFrameURL: 'http://someother.example.com/handle-parse-iframe'
|
|
}
|
|
}))
|
|
|
|
emailAdapter.sendVerificationEmail = (options) => {
|
|
expect(options.link).toEqual('http://someother.example.com/handle-parse-iframe?link=%2Fapps%2Ftest%2Fverify_email&token=testToken&username=testUser')
|
|
done()
|
|
}
|
|
|
|
const userController = new UserController(emailAdapter, 'test', {
|
|
verifyUserEmails: true
|
|
})
|
|
|
|
userController.sendVerificationEmail(user)
|
|
})
|
|
})
|
|
})
|
|
});
|