Skip to content

Commit

Permalink
Adiciona contato do servico #19
Browse files Browse the repository at this point in the history
  • Loading branch information
glauberramos committed Nov 23, 2015
1 parent b29cbde commit 1bbabf2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 25 deletions.
45 changes: 28 additions & 17 deletions bin/cartaParaPdf.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions main.js

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion src/contentBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ cartaParaPdf.ContentBuilder = function(servicoObject) {

function buildDescricao() {
if (servico.descricao) {
var content = [];

addContent({ text: 'O que é?', style: 'subheader' });
addNewLine();
addContent({ text: servico.descricao, style: 'paragraph' });

var textoHtml = markdown.toHTML(servico.descricao);
parseHtml.parseHtml(content, textoHtml);

docContent = docContent.concat(content);

addNewLine();
}
}
Expand Down Expand Up @@ -101,12 +108,26 @@ cartaParaPdf.ContentBuilder = function(servicoObject) {
}
}

function buildContato() {
if(servico.contato) {
var content = [];

addContent({ text: 'Para mais informações ou dúvidas sobre este serviço, entre em contato:', style: 'paragraph' });

var textoHtml = markdown.toHTML(servico.contato);
parseHtml.parseHtml(content, textoHtml);

docContent = docContent.concat(content);
}
}

function buildOutrasInformacoes() {
if (servico.nomesPopulares.length || servico.gratuito) {
addContent({ text: 'Outras informações', style: 'subheader' });
addNewLine();
buildNomesPopulares();
buildGratuidade();
buildContato();
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/servicoParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ cartaParaPdf.ServicoParser = function() {
return $(xmlDoc).find('sigla').html();
};

api.parseContato = function (xmlDoc) {
return $(xmlDoc).find('contato').html();
}

api.parseDescricao = function (xmlDoc) {
return $(xmlDoc).find('descricao').html();
};
Expand Down Expand Up @@ -168,8 +172,7 @@ cartaParaPdf.ServicoParser = function() {

api.parseOrgao = function (xmlDoc) {
return {
id: $(xmlDoc).find('orgao').attr('id'),
contato: $(xmlDoc).find('orgao contato').html()
id: $(xmlDoc).find('orgao').attr('id')
};
};

Expand All @@ -178,6 +181,7 @@ cartaParaPdf.ServicoParser = function() {
servico = {
nome: api.parseNome(xmlDoc),
descricao: api.parseDescricao(xmlDoc),
contato: api.parseContato(xmlDoc),
sigla: api.parseSigla(xmlDoc),
gratuito: api.parseGratuito(xmlDoc),
nomesPopulares: api.parseNomesPopulares(xmlDoc),
Expand Down
16 changes: 15 additions & 1 deletion test/contentBuilderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ describe('Montar conteúdo do serviço', function () {

it('deve adicionar descrição', function () {
var servico = { descricao: 'Descrição teste'},
content = [{ text: 'O que é?', style: 'subheader' }, { text: 'Descrição teste', style: 'paragraph' }];
content = [{ text: 'O que é?', style: 'subheader' },
[{ text: 'Descrição teste', style: 'text', headlineLevel: 2 }]];

contentBuilder = criarContentBuilder(servico);

expect(contentBuilder.buildContent()).toEqual(arrayContaining(content));
Expand Down Expand Up @@ -172,6 +174,18 @@ describe('Montar conteúdo do serviço', function () {
expect(contentBuilder.buildContent()).toEqual(arrayContaining(content));
});

it('deve adicionar contato', function () {
var servico = {
contato: 'seuhfuisefhs'
};
var content = [
{ text: 'Para mais informações ou dúvidas sobre este serviço, entre em contato:', style: 'paragraph' }
];
contentBuilder = criarContentBuilder(servico);

expect(contentBuilder.buildContent()).toEqual(arrayContaining(content));
});

it('deve adicionar outras informações', function () {
var content = [
{ text: 'Outras informações', style: 'subheader' }
Expand Down
8 changes: 6 additions & 2 deletions test/servicoParserTest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1bbabf2

Please sign in to comment.