block_partial_require_test.js 868 B

1234567891011121314151617181920212223242526
  1. var concat = require("concat-stream");
  2. var browserify = require("browserify");
  3. var assert = require("assert");
  4. var vm = require("vm");
  5. var b = browserify(__dirname + "/blockPartialBrowserCode.js");
  6. b.transform(require("hbsfy"), { traverse: true });
  7. var context = {
  8. document: {
  9. body: {}
  10. }
  11. };
  12. b.bundle().pipe(concat(function(data) {
  13. var bundle = data.toString();
  14. assert(/require\('.\/block_partial_required\.hbs'\)/.test(bundle), 'looking for require');
  15. assert(/block_partial_required.hbs['"]\:/.test(bundle), 'looking for included partial');
  16. assert(/var partial\$0/.test(bundle), 'looking for partial temp var');
  17. assert(/, partial\$0/.test(bundle), 'looking for partial registration');
  18. vm.runInNewContext(bundle, context);
  19. }));
  20. setTimeout(function() {
  21. assert.equal(context.document.body.innerHTML.trim(), "<div><p>inside</p></div>");
  22. }, 400);