Skip to content

Instantly share code, notes, and snippets.

@thelinuxlich
Created March 11, 2011 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thelinuxlich/866613 to your computer and use it in GitHub Desktop.
Save thelinuxlich/866613 to your computer and use it in GitHub Desktop.
$(function(){
module("Testes Offline");
var dados = {
nome: "Joao",
sobrenome: "Teste",
cpf: "123.456.789-0",
data_de_nascimento: "01/01/1980",
endereco: "Rua teste",
numero_endereco: "111",
bairro: "Braz Cubas",
cidade: "Mogi das Cruzes",
estado: "SP",
telefone_residencial: "",
telefone_celular: ""
}
test("O ex-funcionário deve ter todos os campos preenchidos, exceto telefone", function() {
VM.funcionario.set(dados);
ok(VM.funcionario.validate(),true);
});
/** Mocks para simular AJAX */
$.mockjax({url: VM.funcionario.__urls["create"],contentType: 'text/json',
responseText: {status: "SUCCESS"}});
$.mockjax({url: VM.funcionario.__urls["show"].replace(":id",*),contentType: 'text/json',
responseText: {status: "SUCCESS",data: dados}});
asyncTest("Ao salvar um funcionário, o cadastro deve ser limpo", function(){
VM.funcionario.set(dados).create(function(data){
if(data.status === "SUCCESS")
VM.funcionario.clear();
ok(VM.funcionario.estado() === "",true);
start();
});
});
asyncTest("O bot&aatildeo de adicionar parcelas deve estar habilitado quando carregar um funcionário já existente", function(){
VM.funcionario.show({id: 1},function(response){
if(response.status === "SUCCESS")
VM.funcionario.set(response.data);
ok(VM.funcionario.nome() === "Joao",true);
ok(VM.habilitaBotaoAdicionarParcelas(),true);
start();
})
});
module("Testes Online");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment