serializer_spec.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. const chai = require('chai');
  3. const sinon = require('sinon');
  4. const sinonChai = require('sinon-chai');
  5. const expect = chai.expect;
  6. chai.use(sinonChai);
  7. describe('Testing serializer', function () {
  8. var Serializer = require('../src/serializer');
  9. it('Availability of the class', function () {
  10. expect(Serializer).not.to.be.undefined;
  11. expect(Serializer).not.to.be.null;
  12. });
  13. it('Instantiate with default params', function () {
  14. var instance = new Serializer();
  15. expect(instance).not.to.be.null;
  16. });
  17. it('serialize should return a correct string with quoted keys', function () {
  18. var instance = new Serializer();
  19. expect(instance.serialize({
  20. production: {
  21. key: 'value'
  22. }
  23. })).to.be.equal('[production]\nkey="value"\n');
  24. });
  25. it('serialize with keep_quotes should return a correct string with and without quotes', function () {
  26. var instance = new Serializer({keep_quotes: true});
  27. expect(instance.serialize({
  28. production: {
  29. quoted: '"quoted"',
  30. not_quoted: 'not_quoted'
  31. }
  32. })).to.be.equal('[production]\nquoted="quoted"\nnot_quoted=not_quoted\n');
  33. });
  34. });