test(log): from Jest to test (#6498)
This commit is contained in:
parent
dc3446d61a
commit
97f852f8e8
@ -1,6 +1,7 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
/* eslint-env jest */
|
const { describe, it } = require('test')
|
||||||
|
const assert = require('assert').strict
|
||||||
|
|
||||||
const { forEach, isInteger } = require('lodash')
|
const { forEach, isInteger } = require('lodash')
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ const { LEVELS, NAMES, resolve } = require('./levels')
|
|||||||
describe('LEVELS', () => {
|
describe('LEVELS', () => {
|
||||||
it('maps level names to their integer values', () => {
|
it('maps level names to their integer values', () => {
|
||||||
forEach(LEVELS, (value, name) => {
|
forEach(LEVELS, (value, name) => {
|
||||||
expect(isInteger(value)).toBe(true)
|
assert.strictEqual(isInteger(value), true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -17,7 +18,7 @@ describe('LEVELS', () => {
|
|||||||
describe('NAMES', () => {
|
describe('NAMES', () => {
|
||||||
it('maps level values to their names', () => {
|
it('maps level values to their names', () => {
|
||||||
forEach(LEVELS, (value, name) => {
|
forEach(LEVELS, (value, name) => {
|
||||||
expect(NAMES[value]).toBe(name)
|
assert.strictEqual(NAMES[value], name)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -25,10 +26,10 @@ describe('NAMES', () => {
|
|||||||
describe('resolve()', () => {
|
describe('resolve()', () => {
|
||||||
it('returns level values either from values or names', () => {
|
it('returns level values either from values or names', () => {
|
||||||
forEach(LEVELS, value => {
|
forEach(LEVELS, value => {
|
||||||
expect(resolve(value)).toBe(value)
|
assert.strictEqual(resolve(value), value)
|
||||||
})
|
})
|
||||||
forEach(NAMES, (name, value) => {
|
forEach(NAMES, (name, value) => {
|
||||||
expect(resolve(name)).toBe(+value)
|
assert.strictEqual(resolve(name), +value)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
@ -27,6 +27,10 @@
|
|||||||
"promise-toolbox": "^0.21.0"
|
"promise-toolbox": "^0.21.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postversion": "npm publish"
|
"postversion": "npm publish",
|
||||||
|
"test": "node--test"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"test": "^3.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
/* eslint-env jest */
|
|
||||||
|
|
||||||
const { compileGlobPattern } = require('./utils')
|
|
||||||
|
|
||||||
describe('compileGlobPattern()', () => {
|
|
||||||
it('works', () => {
|
|
||||||
const re = compileGlobPattern('foo, ba*, -bar')
|
|
||||||
expect(re.test('foo')).toBe(true)
|
|
||||||
expect(re.test('bar')).toBe(false)
|
|
||||||
expect(re.test('baz')).toBe(true)
|
|
||||||
expect(re.test('qux')).toBe(false)
|
|
||||||
})
|
|
||||||
})
|
|
16
@xen-orchestra/log/utils.test.js
Normal file
16
@xen-orchestra/log/utils.test.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const { describe, it } = require('test')
|
||||||
|
const assert = require('assert').strict
|
||||||
|
|
||||||
|
const { compileGlobPattern } = require('./utils')
|
||||||
|
|
||||||
|
describe('compileGlobPattern()', () => {
|
||||||
|
it('works', () => {
|
||||||
|
const re = compileGlobPattern('foo, ba*, -bar')
|
||||||
|
assert.strictEqual(re.test('foo'), true)
|
||||||
|
assert.strictEqual(re.test('bar'), false)
|
||||||
|
assert.strictEqual(re.test('baz'), true)
|
||||||
|
assert.strictEqual(re.test('qux'), false)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user