-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
226 additions
and
228 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
describe('App is configured and working', function () { | ||
it('Given enviroment is set to production') | ||
it('When try to start listen on port 3000') | ||
it('Then stylesheet must be generated') | ||
it('And javascript must be generated') | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
21 changes: 20 additions & 1 deletion
21
...gIsOk/commandCheckDoneSuccessfullySpec.js → spec/modules/check_spec.js
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,103 @@ | ||
import Check from '../../src/modules/check' | ||
|
||
describe('Datasource config is empty', () => { | ||
beforeAll(function () { | ||
process.env['MAIL_SERVICE'] = 'gmail' | ||
process.env['MAIL_USER'] = '[email protected]' | ||
process.env['MAIL_PASS'] = '123' | ||
delete(process.env['GOOGLE_CREDS']) | ||
this.chk = new Check() | ||
}) | ||
it('Given E-mail is configured and could be send', () => { | ||
expect(process.env['MAIL_SERVICE']).toBeDefined() | ||
expect(process.env['MAIL_USER']).toBeDefined() | ||
expect(process.env['MAIL_PASS']).toBeDefined() | ||
}) | ||
it('And Datasource config is empty', () => { | ||
expect(process.env['GOOGLE_SPREADSHEET_KEY']).toBeUndefined() | ||
expect(process.env['GOOGLE_CREDS']).toBeUndefined() | ||
}) | ||
it('When Developer try to check if config is ok', () => {}) | ||
|
||
it('Then output a message with information required', function (done) { | ||
this.chk.isValid(function (err, results) { | ||
expect(err).toBe('As configurações da fonte de dados não foram informados') | ||
done() | ||
}) | ||
}) | ||
|
||
afterAll( () => { | ||
delete process.env['MAIL_SERVICE'] | ||
delete process.env['MAIL_USER'] | ||
delete process.env['MAIL_PASS'] | ||
}) | ||
}) | ||
|
||
describe('Datasource content is empty', () => { | ||
beforeAll(function () { | ||
process.env['MAIL_SERVICE'] = 'gmail' | ||
process.env['MAIL_USER'] = '[email protected]' | ||
process.env['MAIL_PASS'] = '123' | ||
|
||
process.env['GOOGLE_SPREADSHEET_KEY'] = '1sEMeSOtywIqCsBCaHCJlNWYOsujGm_1gxX_FVQ8iBvQ' | ||
this.chk = new Check() | ||
}) | ||
it('Given E-mail is configured and could be send', () => { | ||
expect(process.env['MAIL_SERVICE']).toBeDefined() | ||
expect(process.env['MAIL_USER']).toBeDefined() | ||
expect(process.env['MAIL_PASS']).toBeDefined() | ||
}) | ||
it('And Datasource config is valid', () => { | ||
expect(process.env['GOOGLE_SPREADSHEET_KEY']).toBeDefined() | ||
}) | ||
it('When Developer try to process all subscriptions', () => {}) | ||
it('Then a message must be output with error details', function (done) { | ||
this.chk.isValid(function (err, results) { | ||
expect(err).toBe('Datasource não pode ser vazio.') | ||
done() | ||
}) | ||
}); | ||
afterAll( () => { | ||
delete process.env['MAIL_SERVICE'] | ||
delete process.env['MAIL_USER'] | ||
delete process.env['MAIL_PASS'] | ||
|
||
delete process.env['GOOGLE_SPREADSHEET_KEY'] | ||
}) | ||
}) | ||
|
||
describe('Datasource is not acessible', () => { | ||
beforeAll(function () { | ||
process.env['MAIL_SERVICE'] = 'gmail' | ||
process.env['MAIL_USER'] = '[email protected]' | ||
process.env['MAIL_PASS'] = '123' | ||
|
||
process.env['GOOGLE_SPREADSHEET_KEY'] = 'xxxxxxx' | ||
process.env['GOOGLE_CREDS'] = '{"client_email":"[email protected]","private_key":"ddd"}' | ||
this.chk = new Check() | ||
}) | ||
it('Given E-mail is configured and could be send', () => { | ||
expect(process.env['MAIL_SERVICE']).toBeDefined() | ||
expect(process.env['MAIL_USER']).toBeDefined() | ||
expect(process.env['MAIL_PASS']).toBeDefined() | ||
}) | ||
it('And Datasource config is valid', () => { | ||
expect(process.env['GOOGLE_SPREADSHEET_KEY']).toBeDefined() | ||
expect(process.env['GOOGLE_CREDS']).toBeDefined() | ||
}) | ||
it('When Developer try to check if configs are ok', () => {}) | ||
it('Then output a message with information required', function (done) { | ||
this.chk.isValid(function (err, results) { | ||
expect(err).toEqual('As configurações fornecidas para fonte de dados não são válidosError: HTTP error 400: Bad Request "A planilha deste URL não foi encontrada. Verifique se você tem o URL correto e se o proprietário da planilha não a excluiu."'); | ||
done() | ||
}) | ||
}) | ||
afterAll( () => { | ||
delete process.env['MAIL_SERVICE'] | ||
delete process.env['MAIL_USER'] | ||
delete process.env['MAIL_PASS'] | ||
|
||
delete process.env['GOOGLE_SPREADSHEET_KEY'] | ||
delete process.env['GOOGLE_CREDS'] | ||
}) | ||
}) |
2 changes: 1 addition & 1 deletion
2
.../emailCouldNotBeSendWithSmtpServerSpec.js → spec/modules/mailer_spec.js
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,72 @@ | ||
import Rules from '../../../src/modules/rules' | ||
import Util from '../../support/util' | ||
import Mailer from '../../../src/modules/mailer' | ||
import onRegister from '../../../src/modules/rules/onRegister' | ||
|
||
describe('Subscriber has invalid email (Rules)', () => { | ||
beforeAll(function() { | ||
let u = new Util() | ||
let m = new Mailer() | ||
m.setTransporter(u.mailerTransport()) | ||
|
||
this.rl = new Rules(u.validDatasource()) | ||
this.rl.setMailer(m) | ||
spyOn(this.rl, 'warningOrganizer').and.callThrough() | ||
spyOn(this.rl, 'invalidateSubscriber').and.callThrough() | ||
this.rl.rows[0]["e-mail"] = 'inválidoemail/.com' | ||
}) | ||
it('Given Datasource has at least 1 row', function () { | ||
expect(this.rl.rows.length).toEqual(2) | ||
}) | ||
it('And One Subscriber has invalid email', function() { | ||
expect(this.rl.rows[0]["e-mail"]).toEqual('inválidoemail/.com') | ||
}) | ||
it('When Organizer check if Subscriber fit rules', function (done) { | ||
let that = this | ||
that.rl.validate(function(err, results) { | ||
expect(err).toBe(['E-mail inválido encontrado: inválidoemail/.com'].join('\n')) | ||
expect(that.rl.valid).toBe(false) | ||
done(err, results) | ||
}) | ||
}) | ||
it('Then Organizer must receive a email warning about spreadsheet error', function () { | ||
expect(this.rl.invalidateSubscriber).toHaveBeenCalled() | ||
expect(this.rl.warningOrganizer).toHaveBeenCalled() | ||
}) | ||
it('And Subscriber status should be set to "Inválida"', function () { | ||
expect(this.rl.rows[0]["status"]).toEqual('Inválida') | ||
}) | ||
}) | ||
|
||
describe('Subscriber already receive payment instructions (Rule 1)', () => { | ||
beforeAll(function() { | ||
let u = new Util() | ||
let m = new Mailer() | ||
let r = u.validDatasource() | ||
r[0]['status'] = 'Boleto Enviado' | ||
m.setTransporter(u.mailerTransport()) | ||
|
||
this.rl = new onRegister(r) | ||
this.rl.setMailer(m) | ||
spyOn(this.rl, 'warningOrganizer') | ||
spyOn(this.rl, 'invalidateSubscriber') | ||
spyOn(this.rl, 'sendInstructions').and.callThrough() | ||
spyOn(this.rl, 'markSubscriberReceivedInstructions').and.callThrough() | ||
}) | ||
it('Given Datasource has at least 1 row', function () { | ||
expect(this.rl.rows.length).toEqual(2) | ||
}) | ||
it('And Subscriber email is valid and status is "Boleto Enviado"', function () { | ||
expect(this.rl.rows[0]["status"]).toEqual('Boleto Enviado') | ||
}) | ||
it('When Subscribers not fit rules', function (done) { | ||
let that = this | ||
that.rl.validate(function(err, results) { | ||
expect(that.rl.valid).toBe(true) | ||
done(err, results) | ||
}) | ||
}) | ||
it('Then Subscriber should not be changed', function () { | ||
expect(this.rl.rows[0]["status"]).toEqual('Boleto Enviado') | ||
}) | ||
}) |
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.