localStorage_test.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('mixins/common/localStorage');
  20. var localStorage,
  21. nameCases = [
  22. {
  23. toSet: {
  24. name: 'name'
  25. },
  26. toExpect: 'Name'
  27. },
  28. {
  29. toSet: {
  30. name: null,
  31. controller: {
  32. name: 'samplecontroller'
  33. }
  34. },
  35. toExpect: 'Samplecontroller'
  36. },
  37. {
  38. toSet: {
  39. controller: {
  40. name: 'sampleController'
  41. }
  42. },
  43. toExpect: 'Sample'
  44. }
  45. ];
  46. describe('App.LocalStorage', function () {
  47. beforeEach(function () {
  48. localStorage = Em.Object.create(App.LocalStorage);
  49. });
  50. after(function () {
  51. App.db.cleanUp();
  52. });
  53. describe('#dbNamespace', function () {
  54. nameCases.forEach(function (item) {
  55. it('should be ' + item.toExpect, function () {
  56. localStorage.setProperties(item.toSet);
  57. expect(localStorage.get('dbNamespace')).to.equal(item.toExpect)
  58. });
  59. });
  60. });
  61. describe('#getDBProperty', function () {
  62. it('should take value from DB', function () {
  63. localStorage.set('name', 'name');
  64. localStorage.setDBProperty('key', 'value');
  65. expect(localStorage.getDBProperty('key')).to.equal('value');
  66. });
  67. });
  68. });