a zip code crypto-currency system good for red ONLY

test.webworkers.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* global before:true, beforeEach:true, describe:true, expect:true, it:true, Modernizr:true */
  2. var DRIVERS = [
  3. localforage.INDEXEDDB,
  4. localforage.LOCALSTORAGE,
  5. localforage.WEBSQL
  6. ];
  7. DRIVERS.forEach(function(driverName) {
  8. if ((!localforage.supports(localforage.INDEXEDDB) &&
  9. driverName === localforage.INDEXEDDB) ||
  10. (!localforage.supports(localforage.LOCALSTORAGE) &&
  11. driverName === localforage.LOCALSTORAGE) ||
  12. (!localforage.supports(localforage.WEBSQL) &&
  13. driverName === localforage.WEBSQL)) {
  14. // Browser doesn't support this storage library, so we exit the API
  15. // tests.
  16. return;
  17. }
  18. describe('Web Worker support in ' + driverName, function() {
  19. 'use strict';
  20. before(function(done) {
  21. localforage.setDriver(driverName).then(done);
  22. });
  23. beforeEach(function(done) {
  24. localforage.clear(done);
  25. });
  26. if (!Modernizr.webworkers) {
  27. it.skip('doesn\'t have web worker support');
  28. return;
  29. }
  30. if (driverName === localforage.LOCALSTORAGE ||
  31. driverName === localforage.WEBSQL) {
  32. it.skip(driverName + ' is not supported in web workers');
  33. return;
  34. }
  35. it('saves data', function(done) {
  36. var webWorker = new Worker('/test/webworker-client.js');
  37. webWorker.addEventListener('message', function(e) {
  38. var body = e.data.body;
  39. window.console.log(body);
  40. expect(body).to.be('I have been set');
  41. done();
  42. });
  43. webWorker.addEventListener('error', function(e) {
  44. window.console.log(e);
  45. });
  46. webWorker.postMessage({
  47. driver: driverName,
  48. value: 'I have been set'
  49. });
  50. });
  51. });
  52. });