45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
// release.test
|
|
|
|
/* eslint-env jest */
|
|
|
|
import {
|
|
existsSync,
|
|
readFileSync
|
|
} from 'fs'
|
|
|
|
const pkg = JSON.parse(readFileSync('./package.json'))
|
|
|
|
const esmFile = './dist/oembed-extractor.esm.js'
|
|
const cjsFile = './dist/cjs/oembed-extractor.js'
|
|
const cjsPkg = JSON.parse(readFileSync('./dist/cjs/package.json'))
|
|
|
|
describe('Validate commonjs version output', () => {
|
|
test(`Check if ${cjsFile} created`, () => {
|
|
expect(existsSync(cjsFile)).toBeTruthy()
|
|
})
|
|
const constent = readFileSync(cjsFile, 'utf8')
|
|
const lines = constent.split('\n')
|
|
test('Check if file meta contains package info', () => {
|
|
expect(lines[0].includes(`${pkg.name}@${pkg.version}`)).toBeTruthy()
|
|
expect(lines[0].includes(pkg.author)).toBeTruthy()
|
|
expect(lines[0].includes(pkg.license)).toBeTruthy()
|
|
})
|
|
test('Check if cjs package info updated', () => {
|
|
expect(cjsPkg.name).toEqual(pkg.name)
|
|
expect(cjsPkg.version).toEqual(pkg.version)
|
|
})
|
|
})
|
|
|
|
describe('Validate ESM version output', () => {
|
|
test(`Check if ${esmFile} created`, () => {
|
|
expect(existsSync(esmFile)).toBeTruthy()
|
|
})
|
|
const constent = readFileSync(esmFile, 'utf8')
|
|
const lines = constent.split('\n')
|
|
test('Check if file meta contains package info', () => {
|
|
expect(lines[0].includes(`${pkg.name}@${pkg.version}`)).toBeTruthy()
|
|
expect(lines[0].includes(pkg.author)).toBeTruthy()
|
|
expect(lines[0].includes(pkg.license)).toBeTruthy()
|
|
})
|
|
})
|