Files
meteor/tools/tests/static-html.js
Simon Fridlund 4d37a05fb3 Add mongo-dev-server package (#8853)
* Add mongo-dev-server package

Only start the MongoDB server if this package
is present in the project.

* Small layout/formatting adjustments; updated README.

* Allow tests using fake-mongod to start (fake) Mongo.

* Adjust test stdout matching to be less sensitive to ordering.

* Add `mongo-dev-server` History.md entry.

* Remove mongo start check since the tested for error prevents mongo startup.

* Remove README traling whitespace.

* Bump mongo package version.
2017-07-26 18:08:00 +03:00

61 lines
1.6 KiB
JavaScript

var _ = require('underscore');
var selftest = require('../tool-testing/selftest.js');
var files = require('../fs/files.js');
import { getUrl } from '../utils/http-helpers.js';
import { sleepMs } from '../utils/utils.js';
var Sandbox = selftest.Sandbox;
var MONGO_LISTENING =
{ stdout: " [initandlisten] waiting for connections on port" };
function startRun(sandbox) {
var run = sandbox.run();
run.waitSecs(90); // Running from checkout can take a _long_ time
run.match("myapp");
run.match("proxy");
run.tellMongo(MONGO_LISTENING);
run.match("MongoDB");
return run;
};
// Test that the static-html package works. It's hard to do this from a unit
// test.
selftest.define("static-html - add static content to head and body", () => {
const s = new Sandbox({ fakeMongo: true });
s.createApp('myapp', 'compiler-plugin-static-html');
s.cd('myapp');
const run = startRun(s);
// Test that static content is present in HTML response.
const html = getUrl('http://localhost:3000/');
selftest.expectTrue(
html.indexOf(
`<meta name="viewport" content="width=device-width, initial-scale=1">`
) !== -1
);
selftest.expectTrue(
html.indexOf(
`<div>I have a body, yet no Blaze!</div>`
) !== -1
);
run.stop();
});
// Test that the static-html package throws the right error
selftest.define("static-html - throws error", () => {
const s = new Sandbox({ fakeMongo: true });
s.createApp('myapp', 'compiler-plugin-static-html-error');
s.cd('myapp');
const run = startRun(s);
run.matchBeforeExit("Attributes on <head> not supported");
run.stop();
});