mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-17 21:00:03 -06:00
test: do not hard-code major version number in test
This commit is contained in:
@@ -3,6 +3,7 @@ jest.mock('vue-cli-plugin-foo', () => () => {}, { virtual: true })
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { semver } = require('@vue/cli-shared-utils')
|
||||
const Service = require('../lib/Service')
|
||||
|
||||
const mockPkg = json => {
|
||||
@@ -159,8 +160,9 @@ test('api: assertVersion', () => {
|
||||
const plugin = {
|
||||
id: 'test-assertVersion',
|
||||
apply: api => {
|
||||
expect(() => api.assertVersion(4)).not.toThrow()
|
||||
expect(() => api.assertVersion('^4.0.0-0')).not.toThrow()
|
||||
const majorVersionNumber = semver.major(api.version)
|
||||
expect(() => api.assertVersion(majorVersionNumber)).not.toThrow()
|
||||
expect(() => api.assertVersion(`^${majorVersionNumber}.0.0-0`)).not.toThrow()
|
||||
// expect(() => api.assertVersion('>= 4')).not.toThrow()
|
||||
|
||||
expect(() => api.assertVersion(4.1)).toThrow('Expected string or integer value')
|
||||
|
||||
Reference in New Issue
Block a user