This file contains hidden or 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
var TaskManager = function(){ | |
var taskList = []; | |
return { | |
addTask: function(task){ | |
taskList.push(task); | |
}, | |
tasksCount: function(){ | |
return taskList.length; | |
} |
This file contains hidden or 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
var xhr, requests; | |
before(function { | |
xhr = sinon.useFakeXMLHttpRequest(); | |
requests = []; | |
xhr.onCreate = function (req) { requests.push(req); }; | |
}); | |
after(function () { | |
xhr.restore(); // Limpa o objeto quando estamos trabalhando com globais |
This file contains hidden or 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
{ | |
setUp: function () { | |
this.clock = sinon.useFakeTimers(); | |
}, | |
tearDown: function () { | |
this.clock.restore(); | |
}, | |
describe('Deve usar um timmer de 510ms fixo', (assert) => { |
This file contains hidden or 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
var assert = require('assert'); | |
describe('Array', function() { | |
describe('#indexOf()', function() { | |
it('should return -1 when the value is not present', function() { | |
assert.equal(-1, [1,2,3].indexOf(4)); | |
}); | |
}); | |
}) |
This file contains hidden or 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
var assert = require('assert'); | |
describe('Route', function() { | |
describe('Status test', function() { | |
it('Should return 200 when both the database and the API are ok', | |
function() { //Nosso teste } | |
); | |
it('Should return 503 when the database or the API are offline', | |
function() { //Nosso teste } | |
); | |
}); |
This file contains hidden or 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
describe('Should return 503 when the api or the database are not ok', (assert) => { | |
assert.plan(1) | |
let dbMock = { // Cria um modelo do objeto do banco de dados apenas com as propriedades que a rota chama | |
connection: { | |
readyState: 0 | |
} | |
} | |
func(assert.context.routeContext, null, dbMock) |
This file contains hidden or 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
elem.style.display = ‘none’; | |
elem.style.display = ‘’; | |
elem.textContent = ‘Texto’; | |
elem.style.<seu estilo> = ‘’; | |
elem.innerHTML = ‘' |
This file contains hidden or 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
$(elem).hide(); | |
$(elem).show(); | |
$(elem).text(); | |
$(elem).css(); | |
$(elem).html(); |
This file contains hidden or 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
var counter = 0 | |
function ajax() { | |
let xhr = new XMLHttpRequest() | |
// Abre a conexão para a página | |
xhr.open(‘GET’, ‘<URL>’) | |
xhr.onreadystatechange = () => { | |
counter += 20 // 20% pois são 5 estados | |
if (xhr.readystate === 4 && xhr.status === 200) { | |
console.log(xhr.responseText) // Aqui você tem sua resposta | |
} |
This file contains hidden or 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
var request = new XMLHttpRequest(); | |
request.open(‘GET’, ‘/my/url’, true); | |
request.onload = function() { | |
if (this.status >= 200 && this.status < 400) { | |
// Sucesso! | |
var resp = this.response; | |
} else { | |
// Alcançamos o servidor, mas tivemos um erro | |
} |