logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

sanity_checks.spec.js (1019B)


  1. import { getColors } from 'src/services/theme_data/theme_data.service.js'
  2. const checkColors = (output) => {
  3. expect(output).to.have.property('colors')
  4. Object.entries(output.colors).forEach(([key, v]) => {
  5. expect(v, key).to.be.an('object')
  6. expect(v, key).to.include.all.keys('r', 'g', 'b')
  7. 'rgba'.split('').forEach(k => {
  8. if ((k === 'a' && Object.prototype.hasOwnProperty.call(v, 'a')) || k !== 'a') {
  9. expect(v[k], key + '.' + k).to.be.a('number')
  10. expect(v[k], key + '.' + k).to.be.least(0)
  11. expect(v[k], key + '.' + k).to.be.most(k === 'a' ? 1 : 255)
  12. }
  13. })
  14. })
  15. }
  16. describe('Theme Data utility functions', () => {
  17. const context = require.context('static/themes/', false, /\.json$/)
  18. context.keys().forEach((key) => {
  19. it(`Should render all colors for ${key} properly`, () => {
  20. const { theme, source } = context(key)
  21. const data = source || theme
  22. const colors = getColors(data.colors, data.opacity, 1)
  23. checkColors(colors)
  24. })
  25. })
  26. })