forked from extractus/feed-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.test.js
47 lines (42 loc) · 1.52 KB
/
build.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// release.test
/* eslint-env jest */
import {
existsSync,
readFileSync
} from 'fs'
const pkg = JSON.parse(readFileSync('./package.json'))
const esmFile = './dist/feed-extractor.esm.js'
const cjsFile = './dist/cjs/feed-extractor.js'
const cjsPkg = JSON.parse(readFileSync('./dist/cjs/package.json'))
const cjsType = './dist/cjs/index.d.ts'
describe('Validate commonjs version output', () => {
test(`Check if ${cjsFile} created`, () => {
expect(existsSync(cjsFile)).toBeTruthy()
})
test('Check if cjs type copied', () => {
expect(existsSync(cjsType)).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()
})
})