packages/test.js

30 строки
949 B
JavaScript
Исходник Обычный вид История

2016-11-13 07:29:34 +03:00
const packages = require('.')
const isNumber = require('is-number')
2016-11-13 07:29:34 +03:00
test('is an array', () => {
expect(Array.isArray(packages)).toBe(true)
})
test('has lots of packages', () => {
expect(packages.length).toBeGreaterThan(3300)
})
test('has a high percentage of packages with sourceranks', () => {
const ranked = packages.filter(p => isNumber(p.sourcerank))
const percentage = ranked.length / packages.length * 100
expect(percentage).toBeGreaterThan(85)
})
test('sorts results by sourcerank', () => {
const sourceranks = packages.map(p => p.sourcerank)
expect(sourceranks).toEqual(sourceranks.sort())
})
test('excludes packages like `electron` and `electron-prebuilt`', () => {
const names = packages.map(p => p.name)
expect(names.includes('electron-storage')).toBe(true)
expect(names.includes('electron')).toBe(false)
expect(names.includes('electron-prebuilt')).toBe(false)
expect(names.includes('matcha')).toBe(false)
2016-11-13 07:29:34 +03:00
})