How to use the @hapi/joi.equal function in @hapi/joi

To help you get started, we’ve selected a few @hapi/joi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badges / shields / services / twitch / twitch.tester.js View on Github external
!runnerConfig.private.twitch_client_secret
  if (noToken) {
    console.warn(
      'No Twitch client credentials configured. Service tests will be skipped. Add credentials in local.yml to run these tests.'
    )
  }
  return noToken
}

// the first request would take longer since we need to wait for a token
t.create('Status of andyonthewings')
  .skipWhen(checkShouldSkip)
  .get('/status/andyonthewings.json')
  .expectBadge({
    label: 'twitch',
    message: Joi.equal('live', 'offline').required(),
    link: ['https://www.twitch.tv/andyonthewings'],
  })

// the second request should take shorter time since we can reuse the previous token
t.create('Status of noopkat')
  .skipWhen(checkShouldSkip)
  .get('/status/noopkat.json')
  .expectBadge({
    label: 'twitch',
    message: Joi.equal('live', 'offline').required(),
    link: ['https://www.twitch.tv/noopkat'],
  })
github badges / shields / services / azure-devops / azure-devops-helpers.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { isBuildStatus } = require('../build-status')

const keywords = ['vso', 'vsts', 'azure-devops']

const schema = Joi.object({
  message: Joi.alternatives()
    .try(
      isBuildStatus,
      Joi.equal('unknown'),
      Joi.equal('set up now'),
      Joi.equal('never built')
    )
    .required(),
}).required()

async function fetch(serviceInstance, { url, qs = {}, errorMessages }) {
  // Microsoft documentation: https://docs.microsoft.com/en-us/rest/api/vsts/build/status/get
  const { message: status } = await serviceInstance._requestSvg({
    schema,
    url,
    options: { qs },
    errorMessages,
  })
  return { status }
}
github badges / shields / services / readthedocs / readthedocs.tester.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { isBuildStatus } = require('../build-status')
const t = (module.exports = require('../tester').createServiceTester())

t.create('build status')
  .get('/pip.json')
  .expectBadge({
    label: 'docs',
    message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
  })

t.create('build status for named version')
  .get('/pip/stable.json')
  .expectBadge({
    label: 'docs',
    message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
  })

t.create('build status for named semantic version')
  .get('/scrapy/1.0.json')
  .expectBadge({
    label: 'docs',
    message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
  })
github badges / shields / services / cirrus / cirrus.tester.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { isBuildStatus } = require('../build-status')
const t = (module.exports = require('../tester').createServiceTester())

t.create('cirrus bad repo')
  .get('/github/unknown-identifier/unknown-repo.json')
  .expectBadge({ label: 'build', message: 'unknown' })

t.create('cirrus fully.valid')
  .get('/github/flutter/flutter.json')
  .expectBadge({
    label: 'build',
    message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
  })
github badges / shields / services / test-results.js View on Github external
'use strict'

const Joi = require('@hapi/joi')

const testResultQueryParamSchema = Joi.object({
  compact_message: Joi.equal(''),
  passed_label: Joi.string(),
  failed_label: Joi.string(),
  skipped_label: Joi.string(),
}).required()

function renderTestResultMessage({
  passed,
  failed,
  skipped,
  total,
  passedLabel,
  failedLabel,
  skippedLabel,
  isCompact,
}) {
  const labels = { passedLabel, failedLabel, skippedLabel }
github badges / shields / services / nodeping / nodeping-status.tester.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const t = (module.exports = require('../tester').createServiceTester())

t.create('NodePing status')
  .get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
  .expectBadge({
    label: 'Status',
    message: Joi.equal('up', 'down').required(),
  })

t.create('NodePing status - up')
  .get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
  .intercept(nock =>
    nock('https://nodeping.com')
      .get(
        '/reports/results/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei/1?format=json'
      )
      .reply(200, [{ su: true }])
  )
  .expectBadge({
    label: 'Status',
    message: 'up',
  })
github badges / shields / services / continuousphp / continuousphp.service.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { isBuildStatus, renderBuildStatusBadge } = require('../build-status')
const { BaseJsonService } = require('..')

const schema = Joi.object({
  status: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
}).required()

const statusMap = {
  unstable: 'yellow',
  running: 'blue',
}

module.exports = class ContinuousPhp extends BaseJsonService {
  static get category() {
    return 'build'
  }

  static get route() {
    return {
      base: 'continuousphp',
      pattern: ':provider/:user/:repo/:branch*',
github badges / shields / services / codeclimate / codeclimate-common.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { NotFound } = require('..')

const keywords = ['codeclimate']

const isLetterGrade = Joi.equal('A', 'B', 'C', 'D', 'E', 'F').required()

const repoSchema = Joi.object({
  data: Joi.array()
    .max(1)
    .items(
      Joi.object({
        id: Joi.string().required(),
        relationships: Joi.object({
          latest_default_branch_snapshot: Joi.object({
            data: Joi.object({
              id: Joi.string().required(),
            }).allow(null),
          }).required(),
          latest_default_branch_test_report: Joi.object({
            data: Joi.object({
              id: Joi.string().required(),
github badges / shields / services / travis / travis-build.service.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { isBuildStatus, renderBuildStatusBadge } = require('../build-status')
const { BaseSvgScrapingService } = require('..')

const schema = Joi.object({
  message: Joi.alternatives()
    .try(isBuildStatus, Joi.equal('unknown'))
    .required(),
}).required()

module.exports = class TravisBuild extends BaseSvgScrapingService {
  static get category() {
    return 'build'
  }

  static get route() {
    return {
      base: 'travis',
      format: '(?:(com)/)?(?!php-v)([^/]+/[^/]+?)(?:/(.+?))?',
      capture: ['comDomain', 'userRepo', 'branch'],
    }
  }
github badges / shields / services / codeship / codeship.service.js View on Github external
'use strict'

const Joi = require('@hapi/joi')
const { isBuildStatus, renderBuildStatusBadge } = require('../build-status')
const { BaseSvgScrapingService } = require('..')

const schema = Joi.object({
  message: Joi.alternatives()
    .try(
      isBuildStatus,
      Joi.equal('project not found', 'branch not found', 'ignored', 'blocked')
    )
    .required(),
}).required()

const pendingStatus = 'pending'
const notBuiltStatus = 'not built'

const statusMap = {
  testing: pendingStatus,
  waiting: pendingStatus,
  initiated: pendingStatus,
  stopped: notBuiltStatus,
  ignored: notBuiltStatus,
  blocked: notBuiltStatus,
  infrastructure_failure: 'failed',
}