Skip to content
Will edited this page Mar 14, 2014 · 1 revision

the freedom.js library comes with a set of jasmine integration tests for the core freedom.js APIs which can (and should!) be used to verify the correctness of your provider.

There are, however, several steps you will need to take to run these test on your downstream provider repository. This page attempts to document those requirements.

NPM Packages

You will need to install development dependencies of

freedom
es5-shim
grunt-contrib-jasmine
grunt-contrib-copy

Grunt Tasks

First, you will need a copy of freedom.js in root of your repository when running tests. This is used by the phantom.js web worker as source when creating iframe contexts for providers. This can be done with the following grunt task

copy: {
      preTest: {
        src: ['node_modules/freedom/freedom.js'],
        dest: 'freedom.js'
      }

Next, you will need to get the current set of freedom.js source files for inclusion in your tests. This looks like this at the top of your Gruntfile.js.

var FILES = require('freedom/Gruntfile.js').FILES;
for (var key in FILES) {
  FILES[key] = FILES[key].map(function(str) {
    if (str[0] === '!') {
      return '!node_modules/freedom/' + str.substr(1);
    } else {
      return 'node_modules/freedom/' + str;
    }
  });
};

Finally, you will need to extend the appropriate freedom.js integration tests to work on your module. This will look look like this

    jasmine: {
      freedomIntegration: {
        src: FILES.src.concat(FILES.srcprovider).concat(FILES.jasminehelper).concat(/* TODO: YOUR HELPER */),
        options: {
          specs: 'node_modules/freedom/spec/providers/social/**/*.integration.spec.js',
          keepRunner: false
        }
      }
    }

Test Helper

You will likely need at test helper, to mock out or act on behalf of dependencies needed by your provider. Even if you don't, you'll need it to tell the integration tests where your module lives. The convention used in freedom.js is to look for a variable TEMPLATE for the module URL. An example in the freedom-social-xmpp repository looks like:

TEMPLATE = "/src/social.xmpp.json";