Last active
December 14, 2015 01:39
-
-
Save dzwarg/5007506 to your computer and use it in GitHub Desktop.
Example test setup for JSTest.NET
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
/*global require:true, assert:true */ | |
require(['processor']); | |
var processor = require('processor'); | |
function processorExists() { | |
assert.isNotNull(processor, "'processor' is not defined"); | |
} |
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
/*global define:true */ | |
define('processor', ['module'], function (module) { | |
'use strict'; | |
var processor = { | |
config: module.config() | |
/* ... really awesome code here ... */ | |
}; | |
return processor; | |
}); |
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
using JSTest; | |
using JSTest.ScriptElements; | |
using JSTest.ScriptLibraries; | |
using NUnit.Framework; | |
namespace JSLib.Test | |
{ | |
[TestFixture] | |
public class ProcessorTests | |
{ | |
[Datapoints] | |
public readonly TestCase[] LibraryTests = TestCase.LoadFrom(@"..\..\Test\processor-suite.js"); | |
[Theory] | |
public void Test(TestCase testCase) | |
{ | |
var script = new TestScript { IncludeDefaultBreakpoint = false }; | |
// Append required JavaScript libraries. | |
script.AppendBlock(new JsAssertLibrary()); | |
// Append required JavaScript Files. | |
script.AppendFile(@"..\..\Scripts\require.js"); | |
script.AppendFile(@"..\..\Scripts\processor.js"); | |
script.AppendFile(testCase.TestFile); | |
// Run 'Test'. | |
script.RunTest(testCase); | |
} | |
} | |
} |
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
/*global require:true, assert:true */ | |
require(['renderer']); | |
var renderer = require('renderer'); | |
function rendererExists() { | |
assert.isNotNull(renderer, "'renderer' is not defined"); | |
} |
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
/*global define:true */ | |
define('renderer', ['processor', 'module'], function (processor, module) { | |
'use strict'; | |
var renderer = function (options) { | |
/* ... initialization stuff ... */ | |
renderer.processor = processor || options.processor; | |
}; | |
renderer.prototype = { | |
config: module.config() | |
/* ... module stuff ... */ | |
}; | |
return renderer; | |
}); |
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
using JSTest; | |
using JSTest.ScriptElements; | |
using JSTest.ScriptLibraries; | |
using NUnit.Framework; | |
namespace JSLib.Test | |
{ | |
[TestFixture] | |
public class RendererTests | |
{ | |
[Datapoints] | |
public readonly TestCase[] LibraryTests = TestCase.LoadFrom(@"..\..\Test\renderer-suite.js"); | |
[Theory] | |
public void Test(TestCase testCase) | |
{ | |
var script = new TestScript { IncludeDefaultBreakpoint = false }; | |
// Append required JavaScript libraries. | |
script.AppendBlock(new JsAssertLibrary()); | |
// Append required JavaScript Files. | |
script.AppendFile(@"..\..\Scripts\require.js"); | |
script.AppendFile(@"..\..\Scripts\processor.js"); | |
script.AppendFile(@"..\..\Scripts\renderer.js"); | |
script.AppendFile(testCase.TestFile); | |
// Run 'Test'. | |
script.RunTest(testCase); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment