-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from Kashoo/issue-174-reorganize
Issue 174: Reorganization of source code
- Loading branch information
Showing
71 changed files
with
135 additions
and
30 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
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,4 @@ | ||
{ | ||
"extends": "../.jshintrc", | ||
"mocha" : true | ||
} |
2 changes: 1 addition & 1 deletion
2
...t-definition-properties-validator-spec.js → ...t-definition-properties-validator.spec.js
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
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,16 @@ | ||
// This module comprises the public API for synctos. | ||
|
||
/** | ||
* The sync-function-loader module. Reads sync functions from files. | ||
*/ | ||
exports.syncFunctionLoader = require('./sync-function-loader.js'); | ||
|
||
/** | ||
* The test-helper module. Provides a number of conveniences to test the behaviour of document definitions. | ||
*/ | ||
exports.testHelper = require('./test-helper.js'); | ||
|
||
/** | ||
* The validation-error-formatter module. Formats document validation error messages for use in document definition tests. | ||
*/ | ||
exports.validationErrorFormatter = require('./validation-error-formatter.js'); |
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,10 @@ | ||
var expect = require('chai').expect; | ||
var index = require('./index'); | ||
|
||
describe('Main package module', function() { | ||
it('exposes the public API', function() { | ||
expect(index.syncFunctionLoader).to.equal(require('./sync-function-loader')); | ||
expect(index.testHelper).to.equal(require('./test-helper')); | ||
expect(index.validationErrorFormatter).to.equal(require('./validation-error-formatter')); | ||
}); | ||
}); |
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,65 @@ | ||
var path = require('path'); | ||
var expect = require('chai').expect; | ||
var simpleMock = require('../lib/simple-mock/index.js'); | ||
var mockRequire = require('mock-require'); | ||
|
||
describe('Test environment maker', function() { | ||
var testEnvironmentMaker, fsMock, vmMock; | ||
|
||
beforeEach(function() { | ||
// Mock out the "require" calls in the module under test | ||
fsMock = { readFileSync: simpleMock.stub() }; | ||
mockRequire('fs', fsMock); | ||
|
||
vmMock = { runInThisContext: simpleMock.stub() }; | ||
mockRequire('vm', vmMock); | ||
|
||
testEnvironmentMaker = mockRequire.reRequire('./test-environment-maker.js'); | ||
}); | ||
|
||
afterEach(function() { | ||
// Restore "require" calls to their original behaviour after each test case | ||
mockRequire.stopAll(); | ||
}); | ||
|
||
it('creates a test environment from the input with a filename for stack traces', function() { | ||
verifyParse('my-sync-func-`1`', 'my-original-filename'); | ||
}); | ||
|
||
it('creates a test environment from the input but without a filename', function() { | ||
verifyParse('my-sync-func-\\`2\\`'); | ||
}); | ||
|
||
function verifyParse(rawSyncFunction, originalFilename) { | ||
var envTemplateFileContents = 'template: %SYNC_FUNC_PLACEHOLDER%'; | ||
fsMock.readFileSync.returnWith(envTemplateFileContents); | ||
|
||
var expectedTestEnvString = envTemplateFileContents.replace( | ||
'%SYNC_FUNC_PLACEHOLDER%', | ||
function() { return rawSyncFunction.replace(/\\`/g, function() { return '`'; }); }); | ||
|
||
var expectedResult = { bar: 'foo' }; | ||
var mockVmEnvironment = simpleMock.stub(); | ||
mockVmEnvironment.returnWith(expectedResult); | ||
|
||
vmMock.runInThisContext.returnWith(mockVmEnvironment); | ||
|
||
var result = testEnvironmentMaker.init(rawSyncFunction, originalFilename); | ||
|
||
expect(result).to.eql(expectedResult); | ||
|
||
expect(fsMock.readFileSync.callCount).to.equal(1); | ||
expect(fsMock.readFileSync.calls[0].args).to.eql([ path.resolve(__dirname, '../templates/test-environment-template.js'), 'utf8' ]); | ||
|
||
expect(vmMock.runInThisContext.callCount).to.equal(1); | ||
expect(vmMock.runInThisContext.calls[0].args).to.eql([ | ||
'(' + expectedTestEnvString + ');', | ||
{ | ||
filename: originalFilename, | ||
displayErrors: true | ||
} | ||
]); | ||
|
||
expect(mockVmEnvironment.callCount).to.equal(1); | ||
} | ||
}); |
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.