marklogic-community / roxy

Deployment tool for MarkLogic applications. Also provides optional unit test and XQuery MVC structure
Other
87 stars 66 forks source link

Fix SJS unit testing documentation #859

Closed dmcassel closed 7 years ago

dmcassel commented 7 years ago

https://github.com/marklogic-community/roxy/wiki/Unit-Testing#testing-server-side-javascript-with-server-side-javascript

The example shown looks like:

var test = require('/test/test-helper.xqy');
var simple = require('/lib/simple.sjs');

(function addOnePlusOne() {
  var actual = simple.addOne(1);
  return [
    test.assertEqual(2, actual),
    test.assertNotEqual(5, actual)
  ];
})();

(function addOnePlusTwo() {
  var actual = simple.addOne(2);
  test.assertEqual(3, actual);
})();

That won't return the asserts from addOnePlusOne.

dmcassel commented 7 years ago

Fixed code:

var test = require('/test/test-helper.xqy');
var simple = require('/lib/simple.sjs');

function addOnePlusOne() {
  var actual = simple.addOne(1);
  return [
    test.assertEqual(2, actual),
    test.assertNotEqual(5, actual)
  ];
};

function addOnePlusTwo() {
  var actual = simple.addOne(2);
  return test.assertEqual(3, actual);
};

[].concat(
  addOnePlusOne(),
  addOnePlusTwo()
)