Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
describe('regexp module', function() {
it('should support escaping', function() {
var regexp = require('raptor/regexp');
expect(regexp.escape("hello{world}")).toEqual("hello\\{world\\}");
});
it('should support simple regular expressions', function() {
var regexp = require('raptor/regexp');
//console.log("test?.txt", regexp.simple("test?.txt"));
expect(regexp.simple("test*.txt").test("test12.txt")).toEqual(true);
expect(regexp.simple("test*.txt").test("test1.txt")).toEqual(true);
expect(regexp.simple("test?.txt").test("test12.txt")).toEqual(false);
expect(regexp.simple("test?.txt").test("test1.txt")).toEqual(true);
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
xdescribe('raptor loader module', function() {
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
it('should allow JavaScript resources to be loaded dynamically', function() {
var done = false,
exception = null,
_window = null;
runs(function() {
var jsdom = require('jsdom');
jsdom.env({
html: getTestHtmlUrl('loader-test.html'),
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
describe('pubsub module', function() {
it('should allow basic pub sub on the global channel', function() {
var pubsub = require('raptor/pubsub');
var receivedMessage = null;
var receivedData = null;
var receivedTopic = false;
var thisObj = {};
pubsub.subscribe('some.topic', function(data, message) {
expect(this).toStrictlyEqual(thisObj);
receivedData = data;
receivedMessage = message;
}, thisObj);
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
raptor.find('raptor-legacy');
var legacyRaptor = global.raptor;
describe('legacy raptor module', function() {
it('should support normalizing module IDs', function() {
expect(legacyRaptor.require('json')).toEqual(raptor.require('raptor/json'));
expect(legacyRaptor.require('json.stringify')).toEqual(raptor.require('raptor/json/stringify'));
expect(legacyRaptor.require('json.parse')).toEqual(raptor.require('raptor/json/parse'));
expect(legacyRaptor.require('debug')).toEqual(raptor.require('raptor/debug'));
expect(legacyRaptor.require('listeners')).toEqual(raptor.require('raptor/listeners'));
expect(legacyRaptor.require('logging')).toEqual(raptor.require('raptor/logging'));
expect(legacyRaptor.require('pubsub')).toEqual(raptor.require('raptor/pubsub'));
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
xdescribe('raptor mixins', function() {
it('should support mixins for modules and classes', function() {
raptor.defineMixin(
'test.mixins.MixinA',
function() {
return {
mixinAArgs: arguments,
a1: true,
a2: true
};
});
raptor.defineMixin(
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
describe('modules module', function() {
it('should allow module with no mixins', function() {
var simple = require('test/simple');
expect(simple.testMethod()).toEqual('testMethod');
});
it('should allow module with extensions', function() {
var extensions = require('test/extensions');
expect(extensions.env()).toEqual('server');
expect(extensions.getMessage()).toEqual('Test');
});
it('should allow module with extension patterns', function() {
var extensionPatterns = require('test/extension-patterns');
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
function MockContext() {
this.attributes = {};
this.request = {
headers: {}
};
}
MockContext.prototype = {
getAttributes: function() {
return this.attributes;
}
};
var now = 1357027200000; //new Date(2013, 0, 1, 0, 0, 0, 0).getTime();
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
define.Enum(
'test/enums/simple/Day',
[
"SUN",
"MON",
"TUE",
"WED",
"THU",
"FRI",
"SAT"
]);
define.Enum(
'test/enums/complex/Day',
{
require('./_helper.js');
var raptor = require('raptor');
var define = raptor.createDefine(module);
define.Class(
'test.classes.Bird',
function(require) {
return {
init: function(species) {
this.species = species;
},
getSpecies: function() {
return this.species;
},
isFlighted: function() {
return true;
},
(function() {
/*jshint strict:false */
var raptor = require('raptor'),
legacyRaptor,
global = raptor.global,
logging = require('raptor/logging'),
amdDefine = global.define || raptor.createDefine();
//Create a new global raptor object
global.raptor = legacyRaptor = raptor.extend({}, raptor);
var legacyNamesRE = /^(arrays|json.*|debug|listeners|loader.*|locale.*|logging|pubsub|objects|strings|templating.*|widgets)$/,
normalize = function(id) {
id = raptor.normalize(id);
return legacyNamesRE.test(id) ? 'raptor/' + id : id;
},
normalizeIds = function(ids) {
if (typeof ids === 'string') {
return normalize(ids);
}
else {
return ids.map(normalize);