Skip to content

Commit

Permalink
test: do not rely on ng-add defaults for tests (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 authored Oct 21, 2024
1 parent c0c35e5 commit f487862
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions projects/ngx-meta/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ describe('ng-add schematic', () => {
let runner: SchematicTestRunner
let appTree: Tree

const defaultOptions: NgAddSchema = {
const defaultOptions = {
project: 'test',
routing: false,
}
} satisfies Partial<NgAddSchema>

beforeEach(async () => {
runner = new SchematicTestRunner(
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('ng-add schematic', () => {
let tree: Tree

beforeEach(async () => {
tree = await runner.runSchematic<NgAddSchema>(
tree = await runner.runSchematic<Partial<NgAddSchema>>(
SCHEMATIC_NAME,
defaultOptions,
appTree,
Expand All @@ -61,20 +60,22 @@ describe('ng-add schematic', () => {
shouldAddRootProvider(CORE_PROVIDER, () => tree, standalone)
shouldNotAddRootProvider(ROUTING_PROVIDER, () => tree, standalone)
})
;[true, false].forEach((routing) => {
describe(`when routing option is ${routing}`, () => {
let tree: Tree

describe('when routing option is true', () => {
const routing = true
let tree: Tree
beforeEach(async () => {
tree = await runner.runSchematic<Partial<NgAddSchema>>(
SCHEMATIC_NAME,
{ ...defaultOptions, routing },
appTree,
)
})

beforeEach(async () => {
tree = await runner.runSchematic<NgAddSchema>(
SCHEMATIC_NAME,
{ ...defaultOptions, routing },
appTree,
)
routing
? shouldAddRootProvider(ROUTING_PROVIDER, () => tree, standalone)
: shouldNotAddRootProvider(ROUTING_PROVIDER, () => tree, standalone)
})

shouldAddRootProvider(ROUTING_PROVIDER, () => tree, standalone)
})
})
})
Expand Down

0 comments on commit f487862

Please sign in to comment.