diff --git a/test/app.js b/test/app.js new file mode 100644 index 0000000..4db3f6e --- /dev/null +++ b/test/app.js @@ -0,0 +1,22 @@ +var express = require("express"); + +var app = express(); + + + // read the port from the environment, else set to 3000 + app.set("port", process.env.PORT || 3000); + app.set('view engine', 'ejs'); + +app.get('/', function (req, res) +{ + res.render('index'); +}); + +app.get('/barra.js', function (req, res) +{ + res.render('barra'); +}); + +// instead of starting the application here, export the app so that it can +// be loaded differently based on the use case (running the app vs testing) +module.exports = app; diff --git a/test/views/barra.ejs b/test/views/barra.ejs new file mode 100644 index 0000000..e52e630 --- /dev/null +++ b/test/views/barra.ejs @@ -0,0 +1 @@ +include ../../app/static/barra-brasil.js diff --git a/test/views/index.ejs b/test/views/index.ejs new file mode 100644 index 0000000..24a9b18 --- /dev/null +++ b/test/views/index.ejs @@ -0,0 +1 @@ +include ../../app/templates/exemplo.html diff --git a/test/zombie-test.js b/test/zombie-test.js new file mode 100644 index 0000000..24de67c --- /dev/null +++ b/test/zombie-test.js @@ -0,0 +1,51 @@ +var expect = require("chai").expect, assert = require("chai").assert, + Browser = require("zombie"), + app = require("./app"); + +describe("Testes de conteúdo de HTML da barra", function() { + var server, browser, barraUrl; + barraUrl = "http://localhost:3000/"; + before(function() { + // before ALL the tests, start our node server (on a test port, 3001) + + server = app.listen(3000); + }); + + beforeEach(function() { + // before EACH test, create a new zombie browser + // + // some useful options when things go wrong: + // debug: true = outputs debug information for zombie + // waitDuration: 500 = will only wait 500 milliseconds + // for the page to load before moving on + browser = new Browser(); + browser.runScripts = true; + }); + + after(function() { + // after ALL the tests, close the server + server.close(); + }); + + it("trocar o conteúdo do #barra-brasil pelo correto", function(done) { + browser.visit(barraUrl, function() { + + var inner_barra = browser.document.getElementById("barra-brasil"); + console.log(inner_barra.classList); + expect(inner_barra.innerHTML).to.equal("
"); + done(); + }); + }); + + it("trocar o conteúdo do #footer-brasil pelo correto", function(done) { + browser.visit(barraUrl, function() { + + var inner_barra = browser.document.getElementById("footer-brasil"); + assert(inner_barra.innerHTML === " ", + "Conteúdo do#footer-brasil deve ser o provido pela barra.js"); + + done(); + }); + + }); +}); -- libgit2 0.21.2