Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
iObject committed Aug 21, 2024
1 parent 4e6b8d8 commit bc387e8
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/findNodes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,57 @@ describe('findnode', () => {
end sub
`);
});


it('it works when provide an excludeFiles config', async () => {
program.options.autoFindNode = {

Check failure on line 234 in src/findNodes.spec.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Property 'autoFindNode' does not exist on type 'BsConfig'.

Check failure on line 234 in src/findNodes.spec.ts

View workflow job for this annotation

GitHub Actions / create-package

Property 'autoFindNode' does not exist on type 'BsConfig'.
'excludeFiles': ['components/noreplace/**/*']
};

program.setFile('components/replace/BaseKeyboard.bs', `
sub init()
m.helloText.text = "HELLO ZOMBIE"
end sub
`);

program.setFile('components/replace/BaseKeyboard.xml', `
<component name="BaseKeyboard">
<script uri="BaseKeyboard.bs" />
<children>
<label id="helloText" />
</children>
</component>
`);

let result = await program.getTranspiledFileContents('components/replace/BaseKeyboard.bs');
expect(result.code).to.equal(undent`
sub init()
m.helloText = m.top.findNode("helloText")
m.helloText.text = "HELLO ZOMBIE"
end sub
`);

// Now we test the same code in the folder that should be excluded
program.setFile('components/noreplace/BaseKeyboard.bs', `
sub init()
m.helloText.text = "HELLO ZOMBIE"
end sub
`);

program.setFile('components/noreplace/BaseKeyboard.xml', `
<component name="BaseKeyboard">
<script uri="BaseKeyboard.bs" />
<children>
<label id="helloText" />
</children>
</component>
`);

result = await program.getTranspiledFileContents('components/noreplace/BaseKeyboard.bs');
expect(result.code).to.equal(undent`
sub init()
m.helloText.text = "HELLO ZOMBIE"
end sub
`);
});
});

0 comments on commit bc387e8

Please sign in to comment.