Testing GitIgnore Resource Implementation in GatsbyJS
This test suite validates the GitIgnore resource functionality in Gatsby Recipes, focusing on proper handling of .gitignore file entries. The tests ensure correct creation and management of ignore patterns while preventing duplicate entries.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
gatsbyjs/gatsby
deprecated-packages/gatsby-recipes/src/providers/git/ignore.test.js
const path = require(`path`)
const ignore = require(`./ignore`)
const resourceTestHelper = require(`../resource-test-helper`)
const root = path.join(__dirname, `fixtures`)
describe(`git ignore resource`, () => {
test(`e2e test`, async () => {
await resourceTestHelper({
resourceModule: ignore,
resourceName: `GitIgnore`,
context: { root },
initialObject: { name: `.cache` },
partialUpdate: { id: `.cache`, name: `.cache` },
})
})
test(`does not add duplicate entries`, async () => {
const name = `node_modules`
await ignore.create({ root }, { name })
const result = await ignore.all({ root })
expect(result).toMatchInlineSnapshot(`
Array [
Object {
"id": "node_modules",
"name": "node_modules",
},
]
`)
})
})