Front end of the Slack clone application.

test.nodriver.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* global describe:true, expect:true, it:true, Modernizr:true */
  2. describe('When No Drivers Are Available', function() {
  3. 'use strict';
  4. var DRIVERS = [
  5. localforage.INDEXEDDB,
  6. localforage.LOCALSTORAGE,
  7. localforage.WEBSQL
  8. ];
  9. it('agrees with Modernizr on storage drivers support', function() {
  10. expect(localforage.supports(localforage.INDEXEDDB)).to.be(false);
  11. expect(localforage.supports(localforage.INDEXEDDB))
  12. .to.be(Modernizr.indexeddb);
  13. expect(localforage.supports(localforage.LOCALSTORAGE))
  14. .to.be(false);
  15. expect(localforage.supports(localforage.LOCALSTORAGE))
  16. .to.be(Modernizr.localstorage);
  17. expect(localforage.supports(localforage.WEBSQL)).to.be(false);
  18. expect(localforage.supports(localforage.WEBSQL))
  19. .to.be(Modernizr.websqldatabase);
  20. });
  21. it('fails to load localForage [callback]', function(done) {
  22. localforage.ready(function(err) {
  23. expect(err).to.be.an(Error);
  24. expect(err.message).to.be('No available storage method found.');
  25. done();
  26. });
  27. });
  28. it('fails to load localForage [promise]', function(done) {
  29. localforage.ready().then(null, function(err) {
  30. expect(err).to.be.an(Error);
  31. expect(err.message).to.be('No available storage method found.');
  32. done();
  33. });
  34. });
  35. it('has no driver set', function(done) {
  36. localforage.ready(function() {
  37. expect(localforage.driver()).to.be(null);
  38. done();
  39. });
  40. });
  41. DRIVERS.forEach(function(driverName) {
  42. it('fails to setDriver ' + driverName + ' [callback]', function(done) {
  43. localforage.setDriver(driverName, null, function(err) {
  44. expect(err).to.be.an(Error);
  45. expect(err.message).to.be('No available storage method found.');
  46. done();
  47. });
  48. });
  49. it('fails to setDriver ' + driverName + ' [promise]', function(done) {
  50. localforage.setDriver(driverName).then(null, function(err) {
  51. expect(err).to.be.an(Error);
  52. expect(err.message).to.be('No available storage method found.');
  53. done();
  54. });
  55. });
  56. });
  57. it('fails to setDriver using array parameter [callback]', function(done) {
  58. localforage.setDriver(DRIVERS, null, function(err) {
  59. expect(err).to.be.an(Error);
  60. expect(err.message).to.be('No available storage method found.');
  61. done();
  62. });
  63. });
  64. it('fails to setDriver using array parameter [promise]', function(done) {
  65. localforage.setDriver(DRIVERS).then(null, function(err) {
  66. expect(err).to.be.an(Error);
  67. expect(err.message).to.be('No available storage method found.');
  68. done();
  69. });
  70. });
  71. });