This commit is contained in:
MishaBagger
2023-10-25 09:15:21 +03:00
commit b6c10cc93f
9828 changed files with 1446743 additions and 0 deletions

11
6/node_modules/jasmine-node/spec/AsyncSpec.coffee generated vendored Normal file
View File

@@ -0,0 +1,11 @@
#=============================================================================
# Async spec, that will be time outed
#=============================================================================
describe 'async', ->
it 'should be timed out', ->
waitsFor (-> false), 'MIRACLE', 500
doneFunc = (done) ->
setTimeout(done, 10000)
it "should timeout after 100 ms", doneFunc, 100

4
6/node_modules/jasmine-node/spec/CoffeeSpec.coffee generated vendored Normal file
View File

@@ -0,0 +1,4 @@
describe 'jasmine-node', ->
it 'should pass', ->
expect(1+2).toEqual(3)

22
6/node_modules/jasmine-node/spec/GrammarHelper.coffee generated vendored Normal file
View File

@@ -0,0 +1,22 @@
global.testClass = (description, specDefinitions) ->
suite = jasmine.getEnv().describe('Class: ' + description, specDefinitions)
suite.tags = ['class']
suite.isIntermediate = true;
suite
global.feature = (description, specDefinitions) ->
suite = jasmine.getEnv().describe('Feature: ' + description, specDefinitions)
suite.tags = ['feature']
suite.isIntermediate = true;
suite
global.scenario = (desc, func) ->
suite = jasmine.getEnv().describe('Scenario: ' + desc, func)
suite.tags = ['scenario']
suite.isIntermediate = true;
suite
global.should = (description, specDefinitions) ->
suite = jasmine.getEnv().it('It should ' + description, specDefinitions)
suite.tags = ['should']
suite

6
6/node_modules/jasmine-node/spec/HelperSpec.coffee generated vendored Normal file
View File

@@ -0,0 +1,6 @@
testClass 'HelperLoader', ->
feature 'Loading order', ->
should 'load the helpers before the specs.', ->
expect(true).toBeTruthy()
# will fail to parse the spec if the helper was not loaded first

25
6/node_modules/jasmine-node/spec/SampleSpecs.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
describe('jasmine-node', function(){
it('should pass', function(){
expect(1+2).toEqual(3);
});
it('shows asynchronous test', function(){
setTimeout(function(){
expect('second').toEqual('second');
asyncSpecDone();
}, 1);
expect('first').toEqual('first');
asyncSpecWait();
});
it('shows asynchronous test node-style', function(done){
setTimeout(function(){
expect('second').toEqual('second');
// If you call done() with an argument, it will fail the spec
// so you can use it as a handler for many async node calls
done();
}, 1);
expect('first').toEqual('first');
});
});

100
6/node_modules/jasmine-node/spec/TestSpec.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
describe('jasmine-node-flat', function(){
it('should pass', function(){
expect(1+2).toEqual(3);
});
});
describe('beforeEach Timeout', function(){
beforeEach(function(done) {
setTimeout(done, 1000);
}, 100);
it('should fail', function(){
expect(1+2).toEqual(3);
});
});
describe('afterEach Timeout', function(){
afterEach(function(done) {
setTimeout(done, 1000);
}, 100);
it('should pass and then afterEach will fail', function(){
expect(1+2).toEqual(3);
});
});
describe('Testing some characters', function() {
var chars = ['&', '\'', '"', '<', '>'];
for(var i = 0; i < chars.length; i+=1) {
currentChar = chars[i];
it('should reject ' + currentChar, (function(currentChar) {
expect(false).toEqual(false);
})(currentChar));
}
});
describe('Testing waitsfor functionality', function() {
it("Runs and then waitsFor", function() {
runs(function() {
1+1;
});
waitsFor(function() {
return true === false;
}, "the impossible", 1000);
runs(function() {
expect(true).toBeTruthy();
});
});
});
describe('root', function () {
describe('nested', function () {
xit('nested statement', function () {
expect(1).toBeTruthy();
});
});
it('root statement', function () {
expect(1).toBeTruthy();
});
});
describe("Top level describe block", function() {
it("first it block in top level describe", function() {
expect(true).toEqual(true);
});
describe("Second level describe block", function() {
it("first it block in second level describe", function() {
expect(true).toBe(true);
});
});
it("second it block in top level describe", function() {
expect(true).toEqual(true);
});
});
describe('async', function () {
var request = function (str, func) {
func('1', '2', 'hello world');
};
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("hello world");
done();
});
});
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("hello world");
done();
});
}, 250); // timeout after 250 ms
});

34
6/node_modules/jasmine-node/spec/TimerSpec.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
describe("Manually ticking the Jasmine Mock Clock", function() {
var timerCallback;
beforeEach(function() {
timerCallback = jasmine.createSpy('timerCallback');
jasmine.Clock.useMock();
});
it("causes a timeout to be called synchronously", function() {
setTimeout(timerCallback, 100);
expect(timerCallback).not.toHaveBeenCalled();
jasmine.Clock.tick(101);
expect(timerCallback).toHaveBeenCalled();
});
it("causes an interval to be called synchronously", function() {
setInterval(timerCallback, 100);
expect(timerCallback).not.toHaveBeenCalled();
jasmine.Clock.tick(102);
expect(timerCallback).toHaveBeenCalled();
expect(timerCallback.callCount).toEqual(1);
jasmine.Clock.tick(50);
expect(timerCallback.callCount).toEqual(1);
jasmine.Clock.tick(50);
expect(timerCallback.callCount).toEqual(2);
});
});

174
6/node_modules/jasmine-node/spec/async-callback_spec.js generated vendored Normal file
View File

@@ -0,0 +1,174 @@
describe('async-callback', function() {
var env;
beforeEach(function() {
env = new jasmine.Env();
});
describe('it', function() {
it("should time out if callback is not called", function() {
env.describe("it", function() {
env.it("doesn't wait", function(done) {
expect(1+2).toEqual(3);
});
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
}, 6000);
runs(function() {
expect(env.currentRunner().results().failedCount).toEqual(1);
expect(firstResult(env.currentRunner()).message).toMatch(/timeout/);;
});
});
it("should accept timeout for individual spec", function() {
env.describe("it", function() {
env.it("doesn't wait", function(done) {
expect(1+2).toEqual(3);
}, 250);
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
}, 500);
runs(function() {
expect(env.currentRunner().results().failedCount).toEqual(1);
expect(firstResult(env.currentRunner()).message).toMatch(/timeout/);;
});
});
it("should fail if callback is passed error", function() {
env.describe("it", function() {
env.it("doesn't wait", function(done) {
process.nextTick(function() {
done("Failed asynchronously");
});
});
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
});
runs(function() {
expect(env.currentRunner().results().failedCount).toEqual(1);
expect(firstResult(env.currentRunner()).message).toEqual("Failed asynchronously");
});
});
it("should finish after callback is called", function() {
env.describe("it", function() {
env.it("waits", function(done) {
process.nextTick(function() {
env.currentSpec.expect(1+2).toEqual(3);
done();
});
});
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
}, 2000);
runs(function() {
expect(env.currentRunner().results().passedCount).toEqual(1);
});
});
it('should run in the context of the current spec', function(){
var actualContext;
var jasmineSpecContext;
env.describe("it", function() {
env.it("register context", function(done) {
actualContext = this;
jasmineSpecContext = env.currentSpec;
env.expect(this).toBe(jasmineSpecContext);
done();
});
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
}, 'tested jasmine env runner to run the test', 100);
runs(function() {
expect(actualContext).not.toBe(global);
expect(actualContext).toBe(jasmineSpecContext);
});
});
});
describe("beforeEach", function() {
it("should wait for callback", function() {
env.describe("beforeEach", function() {
var waited = false;
env.beforeEach(function(done) {
process.nextTick(function() {
waited = true;
done();
});
});
env.it("waited", function() {
env.currentSpec.expect(waited).toBeTruthy();
});
});
env.currentRunner().execute();
waitsFor(function() {
return env.currentRunner().results().totalCount > 0;
});
runs(function() {
expect(env.currentRunner().results().passedCount).toEqual(1);
});
});
});
describe("afterEach", function() {
it("should be passed async callback", function() {
var completed = false;
env.describe("afterEach", function() {
env.afterEach(function(done) {
process.nextTick(function() {
done('Failed in afterEach');
completed = true;
});
});
env.it("should pass", function() {
this.expect(1+2).toEqual(3);
});
});
env.currentRunner().execute();
waitsFor(function() {
return completed === true;
});
runs(function() {
expect(env.currentRunner().results().passedCount).toEqual(1);
expect(env.currentRunner().results().failedCount).toEqual(1);
});
});
});
});
function firstResult(runner) {
return runner.results().getItems()[0].getItems()[0].getItems()[0];
}

7
6/node_modules/jasmine-node/spec/helper_spec.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
describe("helper", function() {
it("should load the helpers", function() {
var expectation= expect(true);
expect(typeof(expectation.toHaveProperty)).toBe('function');
});
});

View File

@@ -0,0 +1,9 @@
Literate CoffeeScript
====================
This is a spec using written in Literate CoffeeScript
describe 'Coffee.litcoffee', ->
it 'should pass', ->
expect(1+2).toEqual(3)

View File

@@ -0,0 +1,5 @@
describe('jasmine-node-nested.js', function(){
it('should pass', function(){
expect(1+2).toEqual(3);
});
});

View File

@@ -0,0 +1,5 @@
describe('jasmine-node-nested', function(){
it('should pass', function(){
expect(1+2).toEqual(3);
});
});

View File

@@ -0,0 +1,11 @@
describe('jasmine-node-uber-nested', function(){
it('should pass', function(){
expect(1+2).toEqual(3);
});
describe('failure', function(){
it('should report failure (THIS IS EXPECTED)', function(){
expect(true).toBeFalsy();
});
});
});

495
6/node_modules/jasmine-node/spec/reporter_spec.js generated vendored Normal file
View File

@@ -0,0 +1,495 @@
var jasmineNode = require(__dirname + "/../lib/jasmine-node/reporter").jasmineNode;
describe('TerminalReporter', function() {
beforeEach(function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
});
describe("initialize", function() {
it('initializes print_ from config', function() {
var config = { print: true };
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.print_).toBeTruthy();
});
it('initializes color_ from config', function() {
var config = { color: true }
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.color_).toEqual(jasmineNode.TerminalReporter.prototype.ANSIColors);
});
it('initializes includeStackTrace_ from config', function () {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.includeStackTrace_).toBeTruthy();
});
it('sets the started_ flag to false', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.started_).toBeFalsy();
});
it('sets the finished_ flag to false', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.finished_).toBeFalsy();
});
it('initializes the suites_ array', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.suites_.length).toEqual(0);
});
it('initializes the specResults_ to an Object', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.specResults_).toBeDefined();
});
it('initializes the failures_ array', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.failures_.length).toEqual(0);
});
it('sets the callback_ property to false by default', function() {
var config = {}
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.callback_).toEqual(false)
});
it('sets the callback_ property to onComplete if supplied', function() {
var foo = function() { }
var config = { onComplete: foo }
this.reporter = new jasmineNode.TerminalReporter(config);
expect(this.reporter.callback_).toBe(foo)
});
});
describe('when the report runner starts', function() {
beforeEach(function() {
this.spy = spyOn(this.reporter, 'printLine_');
var runner = {
topLevelSuites: function() {
var suites = [];
var suite = { id: 25 };
suites.push(suite);
return suites;
}
};
this.reporter.reportRunnerStarting(runner);
});
it('sets the started_ field to true', function() {
expect(this.reporter.started_).toBeTruthy();
});
it('sets the startedAt field', function() {
// instanceof does not work cross-context (such as when run with requirejs)
var ts = Object.prototype.toString;
expect(ts.call(this.reporter.startedAt)).toBe(ts.call(new Date()));
});
it('buildes the suites_ collection', function() {
expect(this.reporter.suites_.length).toEqual(1);
expect(this.reporter.suites_[0].id).toEqual(25);
});
});
describe('the summarize_ creates suite and spec tree', function() {
beforeEach(function() {
this.spec = {
id: 1,
description: 'the spec',
isSuite: false
}
});
it('creates a summary object from spec', function() {
var result = this.reporter.summarize_(this.spec);
expect(result.id).toEqual(1);
expect(result.name).toEqual('the spec');
expect(result.type).toEqual('spec');
expect(result.children.length).toEqual(0);
});
it('creates a summary object from suite with 1 spec', function() {
var env = { nextSuiteId: false }
var suite = new jasmine.Suite(env, 'suite name', undefined, undefined);
suite.description = 'the suite';
suite.parentSuite = null;
suite.children_.push(this.spec);
var result = this.reporter.summarize_(suite);
expect(result.name).toEqual('the suite');
expect(result.type).toEqual('suite');
expect(result.children.length).toEqual(1);
var suiteChildSpec = result.children[0];
expect(suiteChildSpec.id).toEqual(1);
});
});
describe('reportRunnerResults', function() {
beforeEach(function() {
this.printLineSpy = spyOn(this.reporter, 'printLine_');
});
it('generates the report', function() {
var failuresSpy = spyOn(this.reporter, 'reportFailures_');
var printRunnerResultsSpy = spyOn(this.reporter, 'printRunnerResults_').
andReturn('this is the runner result');
var callbackSpy = spyOn(this.reporter, 'callback_');
var runner = {
results: function() {
var result = { failedCount: 0 };
return result;
},
specs: function() { return []; }
};
this.reporter.startedAt = new Date();
this.reporter.reportRunnerResults(runner);
expect(failuresSpy).toHaveBeenCalled();
expect(this.printLineSpy).toHaveBeenCalled();
expect(callbackSpy).toHaveBeenCalled();
});
});
describe('reportSpecResults', function() {
beforeEach(function() {
this.printSpy = spyOn(this.reporter, 'print_');
this.spec = {
id: 1,
description: 'the spec',
isSuite: false,
results: function() {
var result = {
passed: function() { return true; }
}
return result;
}
}
});
it('prints a \'.\' for pass', function() {
this.reporter.reportSpecResults(this.spec);
expect(this.printSpy).toHaveBeenCalledWith('.');
});
it('prints an \'F\' for failure', function() {
var addFailureToFailuresSpy = spyOn(this.reporter, 'addFailureToFailures_');
var results = function() {
var result = {
passed: function() { return false; }
}
return result;
}
this.spec.results = results;
this.reporter.reportSpecResults(this.spec);
expect(this.printSpy).toHaveBeenCalledWith('F');
expect(addFailureToFailuresSpy).toHaveBeenCalled();
});
});
describe('addFailureToFailures', function() {
it('adds message and stackTrace to failures_', function() {
var spec = {
suite: {
getFullName: function() { return 'Suite name' }
},
description: 'the spec',
results: function() {
var result = {
items_: function() {
var theItems = new Array();
var item = {
passed_: false,
message: 'the message',
trace: {
stack: 'the stack'
}
}
theItems.push(item);
return theItems;
}.call()
};
return result;
}
};
this.reporter.addFailureToFailures_(spec);
var failures = this.reporter.failures_;
expect(failures.length).toEqual(1);
var failure = failures[0];
expect(failure.spec).toEqual('Suite name the spec');
expect(failure.message).toEqual('the message');
expect(failure.stackTrace).toEqual('the stack');
});
});
describe('prints the runner results', function() {
beforeEach(function() {
this.runner = {
results: function() {
var _results = {
totalCount: 23,
failedCount: 52
};
return _results;
},
specs: function() {
var _specs = new Array();
spec = {
results: function() {
var _results = {
skipped: false
}
return _results;
}
};
_specs.push(spec);
return _specs;
}
};
});
it('uses the specs\'s length, totalCount and failedCount', function() {
var message = this.reporter.printRunnerResults_(this.runner);
expect(message).toEqual('1 test, 23 assertions, 52 failures, 0 skipped\n');
});
});
describe('reports failures', function() {
beforeEach(function() {
this.printSpy = spyOn(this.reporter, 'print_');
this.printLineSpy = spyOn(this.reporter, 'printLine_');
});
it('does not report anything when there are no failures', function() {
this.reporter.failures_ = new Array();
this.reporter.reportFailures_();
expect(this.printLineSpy).not.toHaveBeenCalled();
});
it('prints the failures', function() {
var failure = {
spec: 'the spec',
message: 'the message',
stackTrace: 'the stackTrace'
}
this.reporter.failures_ = new Array();
this.reporter.failures_.push(failure);
this.reporter.reportFailures_();
var generatedOutput =
[ [ '\n' ],
[ '\n' ],
[ ' 1) the spec' ],
[ ' Message:' ],
[ ' the message' ],
[ ' Stacktrace:' ] ];
expect(this.printLineSpy).toHaveBeenCalled();
expect(this.printLineSpy.argsForCall).toEqual(generatedOutput);
expect(this.printSpy).toHaveBeenCalled();
expect(this.printSpy.argsForCall[0]).toEqual(['Failures:']);
expect(this.printSpy.argsForCall[1]).toEqual([' the stackTrace']);
});
it('prints the failures without a Stacktrace', function () {
var config = { includeStackTrace: false };
this.reporter = new jasmineNode.TerminalReporter(config);
this.printSpy = spyOn(this.reporter, 'print_');
this.printLineSpy = spyOn(this.reporter, 'printLine_');
var failure = {
spec: 'the spec',
message: 'the message',
stackTrace: 'the stackTrace'
}
this.reporter.failures_ = new Array();
this.reporter.failures_.push(failure);
this.reporter.reportFailures_();
var generatedOutput =
[ [ '\n' ],
[ '\n' ],
[ ' 1) the spec' ],
[ ' Message:' ],
[ ' the message' ] ];
expect(this.printLineSpy).toHaveBeenCalled();
expect(this.printLineSpy.argsForCall).toEqual(generatedOutput);
expect(this.printSpy).toHaveBeenCalled();
expect(this.printSpy.argsForCall[0]).toEqual(['Failures:']);
expect(this.printSpy.argsForCall[1]).toBeUndefined();
});
});
});
describe('TerminalVerboseReporter', function() {
beforeEach(function() {
var config = {}
this.verboseReporter = new jasmineNode.TerminalVerboseReporter(config);
this.addFailureToFailuresSpy = spyOn(this.verboseReporter, 'addFailureToFailures_');
this.spec = {
id: 23,
results: function() {
return {
failedCount: 1,
getItems: function() {
return ["this is the message"];
}
}
}
};
});
describe('#reportSpecResults', function() {
it('adds the spec to the failures_', function() {
this.verboseReporter.reportSpecResults(this.spec);
expect(this.addFailureToFailuresSpy).toHaveBeenCalledWith(this.spec);
});
it('adds a new object to the specResults_', function() {
this.verboseReporter.reportSpecResults(this.spec);
expect(this.verboseReporter.specResults_[23].messages).toEqual(['this is the message']);
expect(this.verboseReporter.specResults_[23].result).toEqual('failed');
});
});
describe('#buildMessagesFromResults_', function() {
beforeEach(function() {
this.suite = {
id: 17,
type: 'suite',
name: 'a describe block',
suiteNestingLevel: 0,
children: [],
getFullName: function() { return "A spec"; },
};
this.spec = {
id: 23,
type: 'spec',
name: 'a spec block',
children: []
};
this.verboseReporter.specResults_['23'] = {
result: 'passed',
runtime: 200
};
this.verboseReporter.suiteResults_['17'] = {
runtime: 500
};
});
it('does not build anything when the results collection is empty', function() {
var results = [],
messages = [];
this.verboseReporter.buildMessagesFromResults_(messages, results);
expect(messages.length).toEqual(0);
});
it('adds a single suite to the messages', function() {
var results = [],
messages = [];
results.push(this.suite);
this.verboseReporter.buildMessagesFromResults_(messages, results);
expect(messages.length).toEqual(2);
expect(messages[0]).toEqual('');
expect(messages[1]).toEqual('a describe block - 500 ms');
});
it('adds a single spec with success to the messages', function() {
var results = [],
messages = [];
this.passSpy = spyOn(this.verboseReporter.color_, 'pass');
results.push(this.spec);
this.verboseReporter.buildMessagesFromResults_(messages, results);
expect(this.passSpy).toHaveBeenCalled();
expect(messages.length).toEqual(1);
expect(messages[0]).toEqual('a spec block - 200 ms');
});
it('adds a single spec with failure to the messages', function() {
var results = [],
messages = [];
this.verboseReporter.specResults_['23'].result = 'failed';
this.passSpy = spyOn(this.verboseReporter.color_, 'pass');
this.failSpy = spyOn(this.verboseReporter.color_, 'fail');
results.push(this.spec);
this.verboseReporter.buildMessagesFromResults_(messages, results);
expect(this.failSpy).toHaveBeenCalled();
expect(this.passSpy).not.toHaveBeenCalled();
});
it('adds a suite, a suite and a single spec with success to the messages', function() {
var results = [],
messages = [];
var subSuite = new Object();
subSuite.id = '29';
subSuite.type = 'suite';
subSuite.name = 'a sub describe block';
subSuite.suiteNestingLevel = 1;
subSuite.children = [];
subSuite.children.push(this.spec);
this.suite.children.push(subSuite);
results.push(this.suite);
this.verboseReporter.suiteResults_['29'] = {
runtime: 350
};
this.verboseReporter.buildMessagesFromResults_(messages, results);
expect(messages.length).toEqual(5);
expect(messages[0]).toEqual('');
expect(messages[1]).toEqual('a describe block - 500 ms');
expect(messages[2]).toEqual('');
expect(messages[3]).toEqual(' a sub describe block - 350 ms');
expect(messages[4]).toEqual(' a spec block - 200 ms');
});
});
});

15
6/node_modules/jasmine-node/spec/sample_helper.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
(function(){
var objectToString = Object.prototype.toString;
var PRIMITIVE_TYPES = [String, Number, RegExp, Boolean, Date];
jasmine.Matchers.prototype.toHaveProperty = function(prop) {
try {
return prop in this.actual;
}
catch (e) {
return false;
}
}
})();