Files
cypress/scripts/unit/utils-spec.js
Gleb Bahmutov a9dcfdff31 Version in commit subject 563 (#564)
* start unit testing npm version extract

* put short NPM version into trigger commit subject, close #563

* pass appVeyor token to bumpercar
2017-10-05 14:13:11 +00:00

43 lines
1.2 KiB
JavaScript

const snapshot = require('snap-shot-it')
/* eslint-env mocha */
describe('getJustVersion', () => {
const { getJustVersion } = require('../utils')
it('returns semver if passed', () => {
snapshot(getJustVersion('0.20.1'))
})
it('returns semver with tag if passed', () => {
snapshot(getJustVersion('1.0.0-dev'))
})
it('returns name if starts with cypress', () => {
snapshot(getJustVersion('cypress@dev'))
snapshot(getJustVersion('cypress@alpha'))
snapshot(getJustVersion('cypress@0.20.3'))
})
it('returns name if matches cypress', () => {
snapshot(getJustVersion('cypress'))
})
it('extracts version from url', () => {
const url = 'https://foo.com/npm/0.20.3/develop-sha-13992/cypress.tgz'
const version = getJustVersion(url)
snapshot({ url, version })
})
it('extracts version with dev from url', () => {
const url = 'https://foo.com/npm/0.20.3-dev/develop-sha-13992/cypress.tgz'
const version = getJustVersion(url)
snapshot({ url, version })
})
it('for anything else returns the input', () => {
const url = 'babababa'
const version = getJustVersion(url)
snapshot({ url, version })
})
})