forked from enviPath/enviPy
Current Dev State
This commit is contained in:
59
static/js/ketcher2/node_modules/handlebars-wax/test/compile.js
generated
vendored
Normal file
59
static/js/ketcher2/node_modules/handlebars-wax/test/compile.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
import test from 'ava';
|
||||
import { setup } from './helpers/setup';
|
||||
|
||||
test('should pre-fill template-string data', async t => {
|
||||
const { wax } = setup();
|
||||
const waxedTemplate = wax.compile('{{foo}} {{bar}} {{baz}}');
|
||||
|
||||
wax.data({ foo: 'hello', bar: 'world' });
|
||||
|
||||
t.is(waxedTemplate(), 'hello world ');
|
||||
t.is(waxedTemplate({ foo: 'a' }), 'a world ');
|
||||
t.is(waxedTemplate({ bar: 'b' }), 'hello b ');
|
||||
t.is(waxedTemplate({ baz: 'c' }), 'hello world c');
|
||||
});
|
||||
|
||||
test('should pre-fill template-function data', async t => {
|
||||
const { hb, wax } = setup();
|
||||
const template = hb.compile('{{foo}} {{bar}} {{baz}}');
|
||||
const waxedTemplate = wax.compile(template);
|
||||
|
||||
wax.data({ foo: 'hello', bar: 'world' });
|
||||
|
||||
t.is(template(), ' ');
|
||||
t.is(template({ foo: 'a' }), 'a ');
|
||||
t.is(template({ bar: 'b' }), ' b ');
|
||||
t.is(template({ baz: 'c' }), ' c');
|
||||
|
||||
t.is(waxedTemplate(), 'hello world ');
|
||||
t.is(waxedTemplate({ foo: 'a' }), 'a world ');
|
||||
t.is(waxedTemplate({ bar: 'b' }), 'hello b ');
|
||||
t.is(waxedTemplate({ baz: 'c' }), 'hello world c');
|
||||
});
|
||||
|
||||
test('should set registered data as _parent', async t => {
|
||||
const { wax } = setup();
|
||||
const waxedTemplate = wax.compile('{{_parent.foo}} {{foo}}');
|
||||
|
||||
wax.data({ foo: 'hello' });
|
||||
|
||||
t.is(waxedTemplate({ foo: 'world' }), 'hello world');
|
||||
});
|
||||
|
||||
test('should set registered data as @root', async t => {
|
||||
const { wax } = setup();
|
||||
const waxedTemplate = wax.compile('{{@root.foo}} {{foo}}');
|
||||
|
||||
wax.data({ foo: 'hello' });
|
||||
|
||||
t.is(waxedTemplate({ foo: 'world' }), 'hello world');
|
||||
});
|
||||
|
||||
test('should prefer user-specified @root', async t => {
|
||||
const { wax } = setup();
|
||||
const waxedTemplate = wax.compile('{{foo}} {{_parent.foo}} {{@root.foo}} {{@root._parent.foo}}');
|
||||
|
||||
wax.data({ foo: 'hello' });
|
||||
|
||||
t.is(waxedTemplate({ foo: 'world' }, { data: { root: { foo: 'bye' } } }), 'world hello bye hello');
|
||||
});
|
||||
30
static/js/ketcher2/node_modules/handlebars-wax/test/data.js
generated
vendored
Normal file
30
static/js/ketcher2/node_modules/handlebars-wax/test/data.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
import test from 'ava';
|
||||
import { setup } from './helpers/setup';
|
||||
|
||||
test('should not modify data', async t => {
|
||||
const { wax, defaultData } = setup();
|
||||
|
||||
wax.data();
|
||||
|
||||
t.deepEqual(Object.keys(wax.context), defaultData);
|
||||
});
|
||||
|
||||
test('should register data by object', async t => {
|
||||
const { wax } = setup();
|
||||
const foo = 'hello';
|
||||
const bar = 'world';
|
||||
|
||||
wax.data({ foo, bar });
|
||||
|
||||
t.is(wax.context.foo, foo);
|
||||
t.is(wax.context.bar, bar);
|
||||
});
|
||||
|
||||
test('should register data by globbed object', async t => {
|
||||
const { wax } = setup();
|
||||
|
||||
wax.data('./fixtures/data/object/**/*.{js,json}');
|
||||
|
||||
t.is(wax.context.hello, 'world');
|
||||
t.deepEqual(wax.context.good.night, ['chair', 'bear', 'moon']);
|
||||
});
|
||||
65
static/js/ketcher2/node_modules/handlebars-wax/test/decorators.js
generated
vendored
Normal file
65
static/js/ketcher2/node_modules/handlebars-wax/test/decorators.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
import test from 'ava';
|
||||
import { setup } from './helpers/setup';
|
||||
|
||||
test('should not modify decorators', async t => {
|
||||
const { hb, wax, defaultDecorators } = setup();
|
||||
|
||||
wax.decorators().decorators('./fixtures/decorators/bogu*.js');
|
||||
|
||||
t.deepEqual(Object.keys(hb.decorators), defaultDecorators);
|
||||
});
|
||||
|
||||
test('should register decorators by object', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
function foo() {}
|
||||
function bar() {}
|
||||
|
||||
wax.decorators({ foo, bar });
|
||||
|
||||
t.is(hb.decorators.foo, foo);
|
||||
t.is(hb.decorators.bar, bar);
|
||||
});
|
||||
|
||||
test('should register decorators by globbed factory', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.decorators('./fixtures/decorators/factory/**/*.js');
|
||||
|
||||
t.is(typeof hb.decorators.currencyDecimal, 'function');
|
||||
t.is(typeof hb.decorators.currencyFormat, 'function');
|
||||
t.is(typeof hb.decorators.i18nLanguage, 'function');
|
||||
t.is(typeof hb.decorators.i18nCountry, 'function');
|
||||
t.is(hb.decorators.empty, undefined);
|
||||
});
|
||||
|
||||
test('should register decorators by globbed function', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.decorators('./fixtures/decorators/function/**/*.{hbs,js}');
|
||||
|
||||
t.is(typeof hb.decorators['currency-decimal'], 'function');
|
||||
t.is(typeof hb.decorators['currency-format'], 'function');
|
||||
t.is(typeof hb.decorators.language, 'function');
|
||||
t.is(typeof hb.decorators.country, 'function');
|
||||
t.is(hb.decorators.empty, undefined);
|
||||
});
|
||||
|
||||
test('should register decorators by globbed object', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.decorators('./fixtures/decorators/object/**/*.js');
|
||||
|
||||
t.is(typeof hb.decorators.currencyDecimal, 'function');
|
||||
t.is(typeof hb.decorators.currencyFormat, 'function');
|
||||
t.is(typeof hb.decorators.i18nLanguage, 'function');
|
||||
t.is(typeof hb.decorators.i18nCountry, 'function');
|
||||
t.is(hb.decorators.empty, undefined);
|
||||
});
|
||||
|
||||
test('should raise errors', async t => {
|
||||
const { wax } = setup();
|
||||
const template = wax.compile('{{* foo}}');
|
||||
|
||||
t.throws(() => template(), /not a function/i);
|
||||
});
|
||||
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/data/object/good/night.json
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/data/object/good/night.json
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
["chair", "bear", "moon"]
|
||||
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/data/object/hello.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/data/object/hello.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = 'world';
|
||||
12
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/factory/currency.js
generated
vendored
Normal file
12
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/factory/currency.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.register = function (hb) {
|
||||
hb.registerDecorator({
|
||||
currencyDecimal: function (str) {
|
||||
// do stuff
|
||||
},
|
||||
currencyFormat: function (str) {
|
||||
// do stuff
|
||||
}
|
||||
});
|
||||
};
|
||||
12
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/factory/i18n.js
generated
vendored
Normal file
12
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/factory/i18n.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.register = function (hb) {
|
||||
hb.registerDecorator({
|
||||
i18nLanguage: function (lang) {
|
||||
// do stuff
|
||||
},
|
||||
i18nCountry: function (str) {
|
||||
// do stuff
|
||||
}
|
||||
});
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/country.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/country.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (str) {
|
||||
// do stuff
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/currency/decimal.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/currency/decimal.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (str) {
|
||||
// do stuff
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/currency/format.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/currency/format.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (str) {
|
||||
// do stuff
|
||||
};
|
||||
2
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/empty.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/empty.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = null;
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/language.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/function/language.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (str) {
|
||||
// do stuff
|
||||
};
|
||||
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/object/currency.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/object/currency.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
currencyDecimal: function (str) {
|
||||
// do stuff
|
||||
},
|
||||
currencyFormat: function (str) {
|
||||
// do stuff
|
||||
}
|
||||
};
|
||||
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/object/i18n.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/decorators/object/i18n.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
i18nLanguage: function (lang) {
|
||||
// do stuff
|
||||
},
|
||||
i18nCountry: function (str) {
|
||||
// do stuff
|
||||
}
|
||||
};
|
||||
12
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/factory/case.js
generated
vendored
Normal file
12
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/factory/case.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.register = function (hb) {
|
||||
hb.registerHelper({
|
||||
lower: function (str) {
|
||||
return str.toLowerCase();
|
||||
},
|
||||
upper: function (str) {
|
||||
return str.toUpperCase();
|
||||
}
|
||||
});
|
||||
};
|
||||
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/factory/flow.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/factory/flow.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.register = function (hb) {
|
||||
hb.registerHelper('lest', function (a, b) {
|
||||
return a !== b;
|
||||
});
|
||||
hb.registerHelper('when', function (a, b) {
|
||||
return a === b;
|
||||
});
|
||||
};
|
||||
2
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/empty.js
generated
vendored
Normal file
2
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/empty.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = null;
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/flow/lest.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/flow/lest.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function lest(a, b) {
|
||||
return a !== b;
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/flow/when.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/flow/when.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function when(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/lower.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/lower.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function lower(str) {
|
||||
return str.toLowerCase();
|
||||
};
|
||||
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/upper.js
generated
vendored
Normal file
5
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/function/upper.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function upper(str) {
|
||||
return str.toUpperCase();
|
||||
};
|
||||
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/object/bogus.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/object/bogus.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = true;
|
||||
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/object/case.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/object/case.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
lower: function (str) {
|
||||
return str.toLowerCase();
|
||||
},
|
||||
upper: function (str) {
|
||||
return str.toUpperCase();
|
||||
}
|
||||
};
|
||||
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/object/flow.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/helpers/object/flow.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
lest: function (a, b) {
|
||||
return a !== b;
|
||||
},
|
||||
when: function (a, b) {
|
||||
return a === b;
|
||||
}
|
||||
};
|
||||
8
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/factory/components.js
generated
vendored
Normal file
8
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/factory/components.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.register = function (hb) {
|
||||
hb.registerPartial({
|
||||
item: '<li>{{label}}</li>',
|
||||
link: '<a href="{{url}}">{{label}}</a>'
|
||||
});
|
||||
};
|
||||
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/factory/layouts.js
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/factory/layouts.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.register = function (hb) {
|
||||
hb.registerPartial('layout', '<!doctype html>\n<html>\n<head>\n <title>{{{block "title"}}}</title>\n</head>\n<body>\n {{{block "body"}}}\n</body>\n</html>');
|
||||
hb.registerPartial('layout-2col', '{{#extend "layout"}}\n {{#content "body"}}\n {{{block "left"}}}\n {{{block "right"}}}\n {{/content}}\n{{/extend}}');
|
||||
};
|
||||
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/components/item.hbs
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/components/item.hbs
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
<li>{{label}}</li>
|
||||
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/components/link.hbs
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/components/link.hbs
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
<a href="{{url}}">{{label}}</a>
|
||||
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/layout-2col.hbs
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/layout-2col.hbs
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{{#extend "layout"}}
|
||||
{{#content "body"}}
|
||||
{{{block "left"}}}
|
||||
{{{block "right"}}}
|
||||
{{/content}}
|
||||
{{/extend}}
|
||||
9
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/layout.hbs
generated
vendored
Normal file
9
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/function/layout.hbs
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{{block "title"}}}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{{block "body"}}}
|
||||
</body>
|
||||
</html>
|
||||
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/object/components.js
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/object/components.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
item: '<li>{{label}}</li>',
|
||||
link: '<a href="{{url}}">{{label}}</a>'
|
||||
};
|
||||
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/object/layouts.js
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/handlebars-wax/test/fixtures/partials/object/layouts.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
layout: '<!doctype html>\n<html>\n<head>\n <title>{{{block "title"}}}</title>\n</head>\n<body>\n {{{block "body"}}}\n</body>\n</html>',
|
||||
'layout-2col': '{{#extend "layout"}}\n {{#content "body"}}\n {{{block "left"}}}\n {{{block "right"}}}\n {{/content}}\n{{/extend}}'
|
||||
};
|
||||
65
static/js/ketcher2/node_modules/handlebars-wax/test/helpers.js
generated
vendored
Normal file
65
static/js/ketcher2/node_modules/handlebars-wax/test/helpers.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
import test from 'ava';
|
||||
import { setup } from './helpers/setup';
|
||||
|
||||
test('should not modify helpers', async t => {
|
||||
const { hb, wax, defaultHelpers } = setup();
|
||||
|
||||
wax.helpers().helpers('./fixtures/helpers/bogu*.js');
|
||||
|
||||
t.deepEqual(Object.keys(hb.helpers), defaultHelpers);
|
||||
});
|
||||
|
||||
test('should register helpers by object', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
function foo() {}
|
||||
function bar() {}
|
||||
|
||||
wax.helpers({ foo, bar });
|
||||
|
||||
t.is(hb.helpers.foo, foo);
|
||||
t.is(hb.helpers.bar, bar);
|
||||
});
|
||||
|
||||
test('should register helpers by globbed factory', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.helpers('./fixtures/helpers/factory/**/*.js');
|
||||
|
||||
t.is(typeof hb.helpers.lower, 'function');
|
||||
t.is(typeof hb.helpers.upper, 'function');
|
||||
t.is(typeof hb.helpers.lest, 'function');
|
||||
t.is(typeof hb.helpers.when, 'function');
|
||||
t.is(hb.helpers.empty, undefined);
|
||||
});
|
||||
|
||||
test('should register helpers by globbed function', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.helpers('./fixtures/helpers/function/**/*.{hbs,js}');
|
||||
|
||||
t.is(typeof hb.helpers.lower, 'function');
|
||||
t.is(typeof hb.helpers.upper, 'function');
|
||||
t.is(typeof hb.helpers['flow-lest'], 'function');
|
||||
t.is(typeof hb.helpers['flow-when'], 'function');
|
||||
t.is(hb.helpers.empty, undefined);
|
||||
});
|
||||
|
||||
test('should register helpers by globbed object', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.helpers('./fixtures/helpers/object/**/*.js');
|
||||
|
||||
t.is(typeof hb.helpers.lower, 'function');
|
||||
t.is(typeof hb.helpers.upper, 'function');
|
||||
t.is(typeof hb.helpers.lest, 'function');
|
||||
t.is(typeof hb.helpers.when, 'function');
|
||||
t.is(hb.helpers.empty, undefined);
|
||||
});
|
||||
|
||||
test('should raise errors', async t => {
|
||||
const { wax } = setup();
|
||||
const template = wax.compile('{{{foo "bar"}}}');
|
||||
|
||||
t.throws(() => template(), /missing helper/i);
|
||||
});
|
||||
21
static/js/ketcher2/node_modules/handlebars-wax/test/helpers/setup.js
generated
vendored
Normal file
21
static/js/ketcher2/node_modules/handlebars-wax/test/helpers/setup.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var handlebars = require('handlebars');
|
||||
var handlebarsWax = require('../../src/handlebars-wax');
|
||||
|
||||
exports.setup = function setup() {
|
||||
var hb = handlebars.create();
|
||||
var defaultPartials = Object.keys(hb.partials);
|
||||
var defaultHelpers = Object.keys(hb.helpers);
|
||||
var defaultDecorators = Object.keys(hb.decorators);
|
||||
|
||||
var wax = handlebarsWax(hb);
|
||||
var defaultData = Object.keys(wax.context);
|
||||
|
||||
return {
|
||||
hb: hb,
|
||||
wax: wax,
|
||||
defaultPartials: defaultPartials,
|
||||
defaultHelpers: defaultHelpers,
|
||||
defaultDecorators: defaultDecorators,
|
||||
defaultData: defaultData
|
||||
};
|
||||
};
|
||||
111
static/js/ketcher2/node_modules/handlebars-wax/test/partials.js
generated
vendored
Normal file
111
static/js/ketcher2/node_modules/handlebars-wax/test/partials.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
import test from 'ava';
|
||||
import handlebars from 'handlebars';
|
||||
import { setup } from './helpers/setup';
|
||||
|
||||
test('should not modify partials', async t => {
|
||||
const { hb, wax, defaultPartials } = setup();
|
||||
|
||||
wax.partials().partials('./fixtures/helpers/bogu*.js');
|
||||
|
||||
t.deepEqual(Object.keys(hb.partials), defaultPartials);
|
||||
});
|
||||
|
||||
test('should register partials by factory', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
function foo() {}
|
||||
function bar() {}
|
||||
|
||||
wax.partials({
|
||||
register: function (handlebars) {
|
||||
t.is(handlebars, hb);
|
||||
handlebars.registerPartial('foo', foo);
|
||||
}
|
||||
});
|
||||
|
||||
wax.partials({
|
||||
register: function (handlebars) {
|
||||
t.is(handlebars, hb);
|
||||
return { bar };
|
||||
}
|
||||
});
|
||||
|
||||
t.is(hb.partials.foo, foo);
|
||||
t.is(hb.partials.bar, bar);
|
||||
});
|
||||
|
||||
test('should register partials by function', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
function foo() {}
|
||||
function bar() {}
|
||||
|
||||
wax.partials(function (handlebars) {
|
||||
t.is(handlebars, hb);
|
||||
handlebars.registerPartial('foo', foo);
|
||||
});
|
||||
|
||||
wax.partials(function (handlebars) {
|
||||
t.is(handlebars, hb);
|
||||
return { bar };
|
||||
});
|
||||
|
||||
t.is(hb.partials.foo, foo);
|
||||
t.is(hb.partials.bar, bar);
|
||||
});
|
||||
|
||||
test('should register partials by object', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
function foo() {}
|
||||
function bar() {}
|
||||
|
||||
wax.partials({ foo, bar });
|
||||
|
||||
t.is(hb.partials.foo, foo);
|
||||
t.is(hb.partials.bar, bar);
|
||||
});
|
||||
|
||||
test('should register partials by globbed factory', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.partials('./fixtures/partials/factory/**/*.js');
|
||||
|
||||
t.is(typeof hb.partials.item, 'string');
|
||||
t.is(typeof hb.partials.link, 'string');
|
||||
t.is(typeof hb.partials.layout, 'string');
|
||||
t.is(typeof hb.partials['layout-2col'], 'string');
|
||||
});
|
||||
|
||||
test('should register partials by globbed function', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.partials('./fixtures/partials/function/**/*.{hbs,js}');
|
||||
|
||||
t.is(typeof hb.partials['components/item'], 'function');
|
||||
t.is(typeof hb.partials['components/link'], 'function');
|
||||
t.is(typeof hb.partials.layout, 'function');
|
||||
t.is(typeof hb.partials['layout-2col'], 'function');
|
||||
});
|
||||
|
||||
test('should register partials by globbed object', async t => {
|
||||
const { hb, wax } = setup();
|
||||
|
||||
wax.partials('./fixtures/partials/object/**/*.js');
|
||||
|
||||
t.is(typeof hb.partials.item, 'string');
|
||||
t.is(typeof hb.partials.link, 'string');
|
||||
t.is(typeof hb.partials.layout, 'string');
|
||||
t.is(typeof hb.partials['layout-2col'], 'string');
|
||||
});
|
||||
|
||||
test('should raise errors', async t => {
|
||||
const { wax } = setup();
|
||||
const waxedTemplate = wax.compile('{{> foo}}');
|
||||
|
||||
t.throws(() => waxedTemplate(), /could not be found/i);
|
||||
});
|
||||
|
||||
test.after('should not cause cross-contamination', async t => {
|
||||
t.is(Object.keys(handlebars.partials).length, 0);
|
||||
});
|
||||
Reference in New Issue
Block a user