mixer-get-config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 'use strict';
  2. require('jsdom-global')();
  3. const chai = require('chai');
  4. const dom = require('../mock/dom');
  5. const mixitup = require('../../dist/mixitup.js');
  6. chai.use(require('chai-shallow-deep-equal'));
  7. chai.use(require('chai-as-promised'));
  8. describe('mixitup.Mixer', () => {
  9. let container = dom.getContainer();
  10. let mixer = mixitup(container);
  11. describe('#getConfig()', () => {
  12. it('should retrieve the whole config object if no stringKey passed', () => {
  13. let config = mixer.getConfig();
  14. chai.assert.instanceOf(config, mixitup.Config);
  15. });
  16. it('should retrieve a config sub-object if single prop stringKey passed', () => {
  17. let config = mixer.getConfig('animation');
  18. chai.assert.instanceOf(config, mixitup.ConfigAnimation);
  19. });
  20. it('should retrieve a nested property value if multi-prop stringKey passed', () => {
  21. let config = mixer.getConfig('animation.effects');
  22. chai.assert.equal(typeof config, 'string');
  23. });
  24. it('should retrieve a the current configuration, reflective of any changes', () => {
  25. let newEffects = 'fade translateZ(-100px)';
  26. mixer.configure({
  27. animation: {
  28. effects: newEffects
  29. }
  30. });
  31. let newConfig = mixer.getConfig('animation.effects');
  32. chai.assert.equal(newConfig, newEffects);
  33. });
  34. it('should throw an error if an invalid configuration option is passed', function() {
  35. chai.assert.throws(() => {
  36. mixer.configure({
  37. animations: {}
  38. });
  39. }, TypeError, mixitup.messages.errorConfigInvalidProperty({
  40. erroneous: 'animations',
  41. suggestion: mixitup.messages.errorConfigInvalidPropertySuggestion({
  42. probableMatch: 'animation'
  43. })
  44. }));
  45. });
  46. });
  47. });