Skip to content

Commit e9d1c09

Browse files
authored
chore: Add block fixture + assertions for dev command test (#9)
* chore: Add block fixture + assertions for dev command test * Add block test to map command
1 parent a80add2 commit e9d1c09

9 files changed

Lines changed: 18 additions & 2 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/commands/theme/component/dev.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ describe('theme component dev', () => {
3737
await runCommand(['theme', 'component', 'dev', '-t', testThemePath])
3838
expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'sections', 'with-setup.liquid'))).to.be.true
3939
expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'templates', 'index.with-setup.liquid'))).to.be.true
40+
expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'blocks', 'with-setup.liquid'))).to.be.true
41+
expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'blocks', '_with-setup.liquid'))).to.be.true
4042
})
4143

4244
it('merges the settings_schema.json setup files', async () => {

test/commands/theme/component/map.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ describe('theme component map', () => {
9696
expect(data.files.snippets['child.liquid']).to.equal('@archetype-themes/test-collection')
9797
})
9898

99+
it('adds entries for blocks', async () => {
100+
const beforeData = JSON.parse(fs.readFileSync(path.join(testThemePath, 'component.manifest.json'), 'utf8'))
101+
expect(beforeData.files.snippets['section-with-block-snippet.liquid']).to.be.undefined
102+
expect(beforeData.files.snippets['section-with-block-snippet.block.liquid']).to.be.undefined
103+
104+
await runCommand(['theme', 'component', 'map', testThemePath])
105+
106+
const data = JSON.parse(fs.readFileSync(path.join(testThemePath, 'component.manifest.json'), 'utf8'))
107+
expect(data.files.snippets['section-with-block-snippet.liquid']).to.equal('@archetype-themes/test-collection')
108+
expect(data.files.snippets['section-with-block-snippet.block.liquid']).to.equal('@archetype-themes/test-collection')
109+
})
110+
99111
it('throws a warning if there is a potential conflict with an entry in the current collection', async () => {
100112
const {stdout} = await runCommand(['theme', 'component', 'map', testThemePath])
101113
const data = JSON.parse(fs.readFileSync(path.join(testThemePath, 'component.manifest.json'), 'utf8'))

test/fixtures/collection/components/section-with-block-snippet/section-with-block-snippet.liquid

Whitespace-only changes.

test/fixtures/collection/components/section-with-block-snippet/snippets/section-with-block-snippet.block.liquid

Whitespace-only changes.

test/fixtures/collection/components/with-setup/setup/blocks/_with-setup.liquid

Whitespace-only changes.

test/fixtures/collection/components/with-setup/setup/blocks/with-setup.liquid

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% render 'section-with-block-snippet.block' %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% render 'section-with-block-snippet' %}

0 commit comments

Comments
 (0)