Skip to content

Commit

Permalink
fix: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Nov 10, 2023
1 parent fc47e1d commit 89eb518
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
9 changes: 5 additions & 4 deletions tests/linker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { join } from 'node:path'
import { test } from '@japa/runner'
import dedent from 'dedent'
import slash from 'slash'
import { Linker } from '../src/linker'
import { TemplateIndexer } from '../src/template_indexer'

Expand Down Expand Up @@ -51,8 +52,8 @@ test.group('Views Linker | .edge', () => {
const paths = result.map((r) => r.templatePath)

assert.sameDeepMembers(paths, [
join(fs.basePath, 'resources/views/components/button.edge'),
join(fs.basePath, 'resources/views/layouts/base.edge'),
slash(join(fs.basePath, 'resources/views/components/button.edge')),
slash(join(fs.basePath, 'resources/views/layouts/base.edge')),
])
})

Expand Down Expand Up @@ -192,8 +193,8 @@ test.group('Views Linker | .edge', () => {
const paths = result.map((r) => r.templatePath)

assert.sameDeepMembers(paths, [
join(indexer.project.rootPath, 'resources/views/components/button.edge'),
join(indexer.project.rootPath, 'resources/views/pages/admin.edge'),
slash(join(indexer.project.rootPath, 'resources/views/components/button.edge')),
slash(join(indexer.project.rootPath, 'resources/views/pages/admin.edge')),
])
})

Expand Down
25 changes: 13 additions & 12 deletions tests/template_indexer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable sonarjs/no-duplicate-string */
import { join } from 'node:path'
import { test } from '@japa/runner'
import slash from 'slash'
import { TemplateIndexer } from '../src/template_indexer'

test.group('Template indexer | Scan', () => {
Expand All @@ -17,14 +18,14 @@ test.group('Template indexer | Scan', () => {

assert.deepEqual(result, [
{
path: join(fs.basePath, 'resources/views/components/button.edge'),
path: slash(join(fs.basePath, 'resources/views/components/button.edge')),
name: 'components/button',
disk: 'default',
isComponent: true,
componentName: 'button',
},
{
path: join(fs.basePath, 'resources/views/layouts/base.edge'),
path: slash(join(fs.basePath, 'resources/views/layouts/base.edge')),
name: 'layouts/base',
disk: 'default',
isComponent: false,
Expand All @@ -48,28 +49,28 @@ test.group('Template indexer | Scan', () => {

assert.includeDeepMembers(result, [
{
path: join(fs.basePath, 'resources/views/components/button.edge'),
path: slash(join(fs.basePath, 'resources/views/components/button.edge')),
name: 'components/button',
disk: 'default',
isComponent: true,
componentName: 'button',
},
{
path: join(fs.basePath, 'resources/views/layouts/base.edge'),
path: slash(join(fs.basePath, 'resources/views/layouts/base.edge')),
name: 'layouts/base',
disk: 'default',
isComponent: false,
componentName: null,
},
{
path: join(fs.basePath, 'node_modules/@dimer/components/foo.edge'),
path: slash(join(fs.basePath, 'node_modules/@dimer/components/foo.edge')),
name: 'dimerr::components/foo',
disk: 'dimerr',
isComponent: true,
componentName: 'dimerr.foo',
},
{
path: join(fs.basePath, 'node_modules/@dimer/layouts/foo.edge'),
path: slash(join(fs.basePath, 'node_modules/@dimer/layouts/foo.edge')),
name: 'dimerr::layouts/foo',
disk: 'dimerr',
isComponent: false,
Expand Down Expand Up @@ -116,28 +117,28 @@ test.group('Template indexer | Scan', () => {

assert.includeDeepMembers(result, [
{
path: join(fs.basePath, 'resources/views/components/button.edge'),
path: slash(join(fs.basePath, 'resources/views/components/button.edge')),
name: 'components/button',
disk: 'default',
isComponent: true,
componentName: 'button',
},
{
path: join(fs.basePath, 'resources/views/components/button-group.edge'),
path: slash(join(fs.basePath, 'resources/views/components/button-group.edge')),
name: 'components/button-group',
disk: 'default',
isComponent: true,
componentName: 'buttonGroup',
},
{
path: join(fs.basePath, 'resources/views/components/button-group/button.edge'),
path: slash(join(fs.basePath, 'resources/views/components/button-group/button.edge')),
name: 'components/button-group/button',
disk: 'default',
isComponent: true,
componentName: 'buttonGroup.button',
},
{
path: join(fs.basePath, 'resources/views/components/base_test.edge'),
path: slash(join(fs.basePath, 'resources/views/components/base_test.edge')),
name: 'components/base_test',
disk: 'default',
isComponent: true,
Expand All @@ -159,14 +160,14 @@ test.group('Template indexer | Scan', () => {

assert.includeDeepMembers(result, [
{
path: join(fs.basePath, 'node_modules/@dimer/components/foo.edge'),
path: slash(join(fs.basePath, 'node_modules/@dimer/components/foo.edge')),
name: 'dimerr::components/foo',
disk: 'dimerr',
isComponent: true,
componentName: 'dimerr.foo',
},
{
path: join(fs.basePath, 'node_modules/@dimer/layouts/foo.edge'),
path: slash(join(fs.basePath, 'node_modules/@dimer/layouts/foo.edge')),
name: 'dimerr::layouts/foo',
disk: 'dimerr',
isComponent: false,
Expand Down

0 comments on commit 89eb518

Please sign in to comment.