This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE, allowRequire: true is necc to use require in template
- Loading branch information
1 parent
969310f
commit dcfa75d
Showing
7 changed files
with
94 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const path = require('path'); | ||
const expect = require('chai').expect; | ||
|
||
const { | ||
execute, | ||
executeRequireStatement | ||
} = require('../src/execute.js'); | ||
|
||
|
||
describe('execute() - Executes JavaScript passed to it as string', () => { | ||
it('should output added value when addition is performed on two values', () => { | ||
expect( | ||
execute('24 + 12', {}).value | ||
).to.equal(36); | ||
}); | ||
|
||
it('should update value of a to new value', () => { | ||
expect( | ||
execute('a = 22 + 22', {a: 4}).sandbox.a | ||
).to.equal(44); | ||
}); | ||
|
||
it('should not update value that is inside string', () => { | ||
expect( | ||
execute('(() => \'a = b\')()').value | ||
).to.equal('a = b'); | ||
}); | ||
}); | ||
|
||
|
||
describe('executeRequireStatement() - executes the code with require() in its string', () => { | ||
it('should add path native object when required', () => { | ||
expect( | ||
executeRequireStatement('const path = require(\'path\')') | ||
.path.join('test', 'path') | ||
).to.equal(path.join('test', 'path')); | ||
}); | ||
|
||
it('should handle the case of require(\'module\').property', () => { | ||
expect( | ||
executeRequireStatement('const testPath = require(\'path\').join(\'test\',\'path\')') | ||
.testPath | ||
).to.equal(path.join('test', 'path')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters