All files / src/mixins setup.js

100% Statements 8/8
75% Branches 3/4
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40        22x   54x                                   94x 53x     94x   94x 94x       402x        
import { Cloudinary, Util } from 'cloudinary-core';
/**
 * To set up Cloudinary instance in component
 */
export const setup = {
  data() {
    return {
      defaultConfigurations: {}
    }
  },
  inject: {
    contextConfiguration: {
      default: {}
    },
    contextOptions: {
      default: {}
    },
  },
  methods: {
    /**
     * Set up the Cloudinary instance, allowing it later to be used to create URLs
     * @param extraConfigs
     */
    setup(extraConfigs) {
      if (!this.cloudinary) {
        this.cloudinary = new Cloudinary(this.toSnakeCase(this.defaultConfigurations))
      }
 
      this.cloudinary.config(this.toSnakeCase(this.contextOptions))
 
      Eif (extraConfigs) {
        this.cloudinary.config(this.toSnakeCase(extraConfigs))
      }
    },
    toSnakeCase(options) {
      return Util.withSnakeCaseKeys(options)
    }
  }
};