1
1
mirror of https://github.com/primer/css.git synced 2024-11-29 06:02:33 +03:00
css/__tests__/build.test.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

import fs from 'fs'
2021-03-30 08:10:52 +03:00
let distDir
beforeAll(() => {
distDir = fs.readdirSync('./dist')
})
describe('./dist/ folder', () => {
let distCSS, distMap, distJS
beforeAll(() => {
2021-04-01 20:56:12 +03:00
distCSS = distDir.filter(i => i.match(/\.css$/))
distMap = distDir.filter(i => i.match(/\.map$/))
distJS = distDir.filter(i => i.match(/\.js$/))
2021-03-30 08:10:52 +03:00
})
it('is not empty', () => {
expect(distDir).not.toBeNull()
expect(distDir.length).not.toBe(0)
})
it('contains source maps', () => {
2021-04-01 20:56:12 +03:00
for (const file of distCSS) {
if (file.includes('support')) { continue }
2021-03-30 08:10:52 +03:00
expect(distMap).toContain(`${file}.map`)
2021-04-01 20:56:12 +03:00
}
2021-03-30 08:10:52 +03:00
})
it('contains stats export files', () => {
2021-04-01 20:56:12 +03:00
for (const file of distCSS) {
expect(distJS).toContain(file.replace('.css', '.js'))
}
2021-03-30 08:10:52 +03:00
})
it('contains stats/ folder', () => {
expect(distDir).toContain('stats')
})
})
describe('./dist/stats/ folder', () => {
let statsDir
beforeAll(() => {
statsDir = fs.readdirSync('./dist/stats')
})
it('is not empty', () => {
expect(statsDir).not.toBeNull()
expect(statsDir.length).not.toBe(0)
})
it('contains a css file for each stat file', () => {
2021-04-01 20:56:12 +03:00
for (const file of statsDir) {
expect(distDir).toContain(file.replace('.json', '.css'))
}
2021-03-30 08:10:52 +03:00
})
})