Skip to content

Commit

Permalink
🧪 test(none): improve @roots/bud-entrypoints coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kellymears committed Jun 21, 2024
1 parent 38e8844 commit 1ee7d01
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
3 changes: 2 additions & 1 deletion sources/@roots/bud-entrypoints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"module": "./lib/index.js",
"devDependencies": {
"@skypack/package-check": "0.2.2",
"@types/node": "20.12.8"
"@types/node": "20.12.8",
"vitest": "1.6.0"
},
"dependencies": {
"@roots/bud": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion sources/@roots/bud-entrypoints/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import type {ExtensionApi} from '@roots/bud-framework/extension'

import BudEntrypoints from './extension.js'
import BudEntrypoints from './extension/index.js'

declare module '@roots/bud-framework' {
interface Bud {
Expand Down
43 changes: 39 additions & 4 deletions sources/@roots/bud-entrypoints/test/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
import Extension from '@roots/bud-entrypoints'
import {describe, expect, it} from 'vitest'
import type {Bud} from '@roots/bud-framework'

import {factory} from '@repo/test-kit'
import EntrypointsWebpackPlugin from '@roots/entrypoints-webpack-plugin'
import {beforeEach, describe, expect, it, vi} from 'vitest'

import BudEntrypoints from '../src/extension/index.js'
import DefaultExport from '../src/index.js'

describe(`@roots/bud-entrypoints`, () => {
it(`should be constructable`, () => {
expect(Extension).toBeInstanceOf(Function)
let bud: Bud
let entrypoints: BudEntrypoints

beforeEach(async () => {
bud = await factory()
entrypoints = new BudEntrypoints(bud)
})

it(`should be instantiable`, () => {
expect(entrypoints).toBeInstanceOf(BudEntrypoints)
})

it(`should have a default export`, () => {
expect(DefaultExport).toBe(BudEntrypoints)
})

it(`should have a plugin property`, () => {
expect(entrypoints.plugin).toBe(EntrypointsWebpackPlugin)
})

it(`should have expected default options`, () => {
expect(entrypoints.options).toStrictEqual({
emitHtml: false,
publicPath: bud.publicPath(),
type: `object`,
})
})

it(`should use the updated publicPath value if the publicPath is updated`, async () => {
bud.setPublicPath(`test/`)
expect(entrypoints.options?.publicPath).toBe(`test/`)
})
})
12 changes: 12 additions & 0 deletions sources/@roots/bud-entrypoints/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {defineConfig} from 'vitest/config'

export default defineConfig({
test: {
coverage: {
exclude: [`**/types/*.ts`],
include: [`src/**/*.ts`],
provider: `v8`,
},
include: [`test/**/*.test.ts`, `test/**/*.test.tsx`],
},
})
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11583,6 +11583,7 @@ __metadata:
"@skypack/package-check": "npm:0.2.2"
"@types/node": "npm:20.12.8"
tslib: "npm:2.6.2"
vitest: "npm:1.6.0"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 1ee7d01

Please sign in to comment.