本文整理汇总了TypeScript中mocha.it函数的典型用法代码示例。如果您正苦于以下问题:TypeScript it函数的具体用法?TypeScript it怎么用?TypeScript it使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了it函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe(RootApi.name, () => {
it('should add button', () => {
const api = createApi();
const b = api.addButton({
title: 'push',
});
assert.strictEqual(b.controller.button.title, 'push');
});
it('should add folder', () => {
const api = createApi();
const f = api.addFolder({
title: 'folder',
});
assert.strictEqual(f.controller.folder.title, 'folder');
assert.strictEqual(f.controller.folder.expanded, true);
});
it('should add collapsed folder', () => {
const api = createApi();
const f = api.addFolder({
expanded: false,
title: 'folder',
});
assert.strictEqual(f.controller.folder.expanded, false);
});
it('should add separator', () => {
const api = createApi();
api.addSeparator();
const cs = api.controller.uiControllerList.items;
assert.instanceOf(cs[cs.length - 1], SeparatorController);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:35,代码来源:root-ui-test.ts
示例2: describe
describe(MonitorBindingApi.name, () => {
it('should listen update event', (done) => {
const PARAMS = {
foo: 0,
};
const api = createApi(new Target(PARAMS, 'foo'));
api.on('update', (value) => {
assert.strictEqual(value, 123);
done();
});
PARAMS.foo = 123;
const ticker = api.controller.binding.ticker;
if (ticker instanceof ManualTicker) {
ticker.tick();
}
});
it('should refresh bound value', () => {
const PARAMS = {
foo: 0,
};
const api = createApi(new Target(PARAMS, 'foo'));
PARAMS.foo = 123;
api.refresh();
assert.strictEqual(api.controller.binding.value.rawValues[0], 123);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:31,代码来源:monitor-binding-test.ts
示例3: EPub
mocha.describe('EPub', () => {
mocha.it('init', () => {
const epub = new EPub('./example/alice.epub');
assert.strictEqual(
epub.imageroot,
`/images/`
);
});
mocha.it('basic parsing', () => {
const epub = new EPub('./example/alice.epub');
epub.parse();
assert.strictEqual(
epub.imageroot,
`/images/`
);
});
mocha.it('supports empty chapters', () => {
var branch = [{navLabel: { text: '' }}];
const epub = new EPub();
var res = epub.walkNavMap(branch, [], []);
assert.ok(res);
});
});
开发者ID:julien-c,项目名称:epub,代码行数:26,代码来源:test.ts
示例4: describe
describe('create', () => {
it('should create an image with n o background', async () => {
const output = 'create-blank.png';
await run('create', '-w', '100', '--he', '200', '-o', output);
fs.readFileSync(output).should.be.deepEqual(
fs.readFileSync(makePath(__dirname, `./images/${output}`))
);
fs.unlinkSync(output);
});
it('should create an image with a background', async () => {
const output = 'create.png';
await run(
'create',
'-w',
'100',
'--he',
'200',
'-b',
0xff0000ff,
'-o',
output
);
fs.readFileSync(output).should.be.deepEqual(
fs.readFileSync(makePath(__dirname, `./images/${output}`))
);
fs.unlinkSync(output);
});
});
开发者ID:oliver-moran,项目名称:jimp,代码行数:33,代码来源:index.test.ts
示例5: describe
describe(StepConstraint.name, () => {
it('should constrain value with step', () => {
const c = new StepConstraint({
step: 1,
});
assert.closeTo(c.constrain(-0.51), -1, DELTA);
assert.closeTo(c.constrain(-0.5), -1, DELTA);
assert.closeTo(c.constrain(-0.49), 0, DELTA);
assert.closeTo(c.constrain(0), 0, DELTA);
assert.closeTo(c.constrain(1.49), 1, DELTA);
assert.closeTo(c.constrain(1.5), 2, DELTA);
assert.closeTo(c.constrain(1.51), 2, DELTA);
});
it('should constrain value with decimal step', () => {
const c = new StepConstraint({
step: 0.2,
});
assert.closeTo(c.constrain(-1.51), -1.6, DELTA);
assert.closeTo(c.constrain(-1.5), -1.6, DELTA);
assert.closeTo(c.constrain(-1.49), -1.4, DELTA);
assert.closeTo(c.constrain(0), 0, DELTA);
assert.closeTo(c.constrain(1.49), 1.4, DELTA);
assert.closeTo(c.constrain(1.5), 1.6, DELTA);
assert.closeTo(c.constrain(1.51), 1.6, DELTA);
});
it('should get step', () => {
const c = new StepConstraint({
step: 0.2,
});
assert.strictEqual(c.step, 0.2);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:34,代码来源:step-test.ts
示例6: describe
describe('Preset', () => {
it('should export JSON', () => {
const PARAMS = {
bar: 'hello',
foo: 1,
};
const preset = Preset.exportJson([
new Target(PARAMS, 'foo'),
new Target(PARAMS, 'bar'),
]);
assert.deepStrictEqual(preset, {
bar: 'hello',
foo: 1,
});
});
it('should import JSON', () => {
const PARAMS = {
bar: 'hello',
foo: 1,
};
const targets = [new Target(PARAMS, 'foo'), new Target(PARAMS, 'bar')];
const preset = Preset.exportJson(targets);
preset.foo = 123;
preset.bar = 'world';
Preset.importJson(targets, preset);
assert.strictEqual(PARAMS.foo, 123);
assert.strictEqual(PARAMS.bar, 'world');
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:34,代码来源:preset-test.ts
示例7: describe
describe(TextInputController.name, () => {
it('should get value', () => {
const value = new InputValue(0);
const doc = TestUtil.createWindow().document;
const c = new TextInputController(doc, {
formatter: new NumberFormatter(2),
parser: NumberParser,
value: value,
});
assert.strictEqual(c.value, value);
});
it('should apply input to value', () => {
const value = new InputValue(0);
const win = TestUtil.createWindow();
const doc = win.document;
const c = new TextInputController(doc, {
formatter: new NumberFormatter(2),
parser: NumberParser,
value: value,
});
c.view.inputElement.value = '3.14';
c.view.inputElement.dispatchEvent(new (win as any).Event('change'));
assert.strictEqual(c.value.rawValue, 3.14);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:29,代码来源:text-test.ts
示例8: describe
describe('Context', () => {
it('exposes simple bindings', () => {
let context = new Context();
assert.ok(context.bind('foo', 1));
assert.ok(context.bind('foo', 1));
assert.notOk(context.bind('foo', 2));
assert.deepEqual(flattenPrototype(context.expose()), { foo: 1 });
});
it('exposes and can discard provisional bindings', () => {
let context = new Context();
assert.ok(context.bind('foo', 1));
let provisional = context.createProvisionalContext();
assert.notOk(provisional.bind('foo', 2));
assert.ok(provisional.bind('bar', 3));
assert.deepEqual(flattenPrototype(context.expose()), { foo: 1 });
assert.deepEqual(flattenPrototype(provisional.expose()), { foo: 1, bar: 3 });
provisional.commit();
assert.deepEqual(flattenPrototype(context.expose()), { foo: 1, bar: 3 });
});
});
开发者ID:salsify,项目名称:botanist,代码行数:26,代码来源:context-test.ts
示例9: describe
describe('buildStateProxyObject', () => {
it('Should proxy state getter', () => {
const initialState = {
message: 'messageValue'
};
const result = buildStateProxyObject(initialState, null, key => initialState[key]);
assert.ok(result.message);
assert.equal(result.message, 'messageValue');
});
it('Should proxy to models', () => {
const model: IModel = {
$state: { message2: 'message2Value' },
signals: {},
models: {}
};
const models = {
submodel: model
}
const result = buildStateProxyObject(null, models, null);
assert.ok(result.submodel, 'submodel');
assert.ok(result.submodel.message2, 'submodel.message2');
assert.equal(result.submodel.message2, 'message2Value');
});
});
开发者ID:pvasek,项目名称:vux,代码行数:27,代码来源:utils.ts
示例10: describe
describe('ColorConverter', () => {
it('should convert mixed to color', () => {
// tslint:disable:object-literal-sort-keys
assert.deepStrictEqual(ColorConverter.fromMixed('#112233').toObject(), {
r: 0x11,
g: 0x22,
b: 0x33,
});
assert.deepStrictEqual(ColorConverter.fromMixed('foobar').toObject(), {
r: 0,
g: 0,
b: 0,
});
assert.deepStrictEqual(ColorConverter.fromMixed(123).toObject(), {
r: 0,
g: 0,
b: 0,
});
});
it('should convert color to string', () => {
assert.strictEqual(ColorConverter.toString(new Color(0, 0, 0)), '#000000');
assert.strictEqual(
ColorConverter.toString(new Color(0, 127, 255)),
'#007fff',
);
assert.strictEqual(
ColorConverter.toString(new Color(255, 255, 255)),
'#ffffff',
);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:32,代码来源:color-test.ts
示例11: describe
describe('diff helper', () => {
it('diff helper', done => {
setUpCli(['diff', testImage1, testImage2], (output, result) => {
output.should.be.exactly('diff');
result.should.be.exactly(0.9747570461662795);
done();
}).argv;
});
it('outputs a diff image to default path', done => {
setUpCli(['diff', testImage1, testImage2, '-o'], () => {}).argv;
setTimeout(() => {
fs.existsSync('diff.png').should.be.exactly(true);
fs.unlinkSync('diff.png');
done();
}, 1000);
});
it('outputs a diff image to default path', done => {
setUpCli(['diff', testImage1, testImage2, '-o', 'custom.png'], () => {})
.argv;
setTimeout(() => {
fs.existsSync('custom.png').should.be.exactly(true);
fs.unlinkSync('custom.png');
done();
}, 2000);
});
});
开发者ID:oliver-moran,项目名称:jimp,代码行数:30,代码来源:cli.test.ts
示例12: describe
describe(PaneError.name, () => {
it('should instanciate for invalid parameters', () => {
const e = new PaneError({
context: {
name: 'foo',
},
type: 'invalidparams',
});
assert.strictEqual(e.type, 'invalidparams');
});
it('should instanciate for no matching controller', () => {
const e = new PaneError({
context: {
key: 'foo',
},
type: 'nomatchingcontroller',
});
assert.strictEqual(e.type, 'nomatchingcontroller');
});
it('should instanciate for empty value', () => {
const e = new PaneError({
context: {
key: 'foo',
},
type: 'emptyvalue',
});
assert.strictEqual(e.type, 'emptyvalue');
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:34,代码来源:pane-error-test.ts
示例13: describe
describe(Foldable.name, () => {
it('should get initial expanded', () => {
const f = new Foldable();
assert.strictEqual(f.expanded, false);
});
it('should set expanded', () => {
const f = new Foldable();
f.expanded = true;
assert.strictEqual(f.expanded, true);
});
it('should emit change event', (done) => {
const f = new Foldable();
f.emitter.on('change', () => {
done();
});
f.expanded = true;
});
it('should not emit change event for no changes', () => {
const f = new Foldable();
f.expanded = true;
f.emitter.on('change', () => {
throw new Error('should not be called');
});
f.expanded = true;
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:30,代码来源:foldable-test.ts
示例14: describe
describe('match()', () => {
let matchRegex = (regex: RegExp) => (name: string) => match(regex, name);
it('accepts the right stuff', () => {
assertMatch(matchRegex(/b/), 'abc', ['b']);
assertMatch(matchRegex(/abc/), 'abc', ['abc']);
assertMatch(matchRegex(/\d+/), 123, ['123']);
assertMatch(matchRegex(/a(b|c)d/), 'abd', ['b', 'abd']);
assertMatch(matchRegex(/a(b|c)d/), 'acd', ['c', 'acd']);
assertMatch(matchRegex(/(a(bc(de)f))(g)/), 'abcdefg', ['abcdef', 'bcdef', 'de', 'g', 'abcdefg']);
assertMatch(matchRegex(/.*/), undefined, ['undefined']);
assertMatch(matchRegex(/.*/), null, ['null']);
assertMatch(matchRegex(/.*/), true, ['true']);
assertMatch(matchRegex(/.*/), new class {}, ['[object Object]']);
assertMatch(matchRegex(/.*/), new class { toString() { return 'hi'; } }, ['hi']);
});
it('rejects the right stuff', () => {
assertNoMatch(matchRegex(/.*/), {});
assertNoMatch(matchRegex(/.*/), []);
assertNoMatch(matchRegex(/foo/), '');
assertNoMatch(matchRegex(/abc/), null);
assertNoMatch(matchRegex(/^abc$/), 'abcd');
});
});
开发者ID:salsify,项目名称:botanist,代码行数:25,代码来源:binding-matchers-test.ts
示例15: describe
describe('.textFromHtml', () => {
it('should not change unformatted text', () => {
expect(textFromHtml('hi there, this is some text. <>!@#$%^&*()_+{}|[]')).to.eql('hi there, this is some text. <>!@#$%^&*()_+{}|[]');
});
it('should convert <em>...</em> to _..._', () => {
expect(textFromHtml('<em>emphasis</em>')).to.eql('_emphasis_');
expect(textFromHtml('this is <em>emphasis</em>...')).to.eql('this is _emphasis_...');
expect(textFromHtml('<em><>!@#$%^&*()_+{}|[]</em>')).to.eql('_<>!@#$%^&*()_+{}|[]_');
});
it('should convert <strong>...</strong> to **...**', () => {
expect(textFromHtml('<strong>strong</strong>')).to.eql('**strong**');
expect(textFromHtml('this is <strong>strong</strong>...')).to.eql('this is **strong**...');
expect(textFromHtml('<strong><>!@#$%^&*()_+{}|[]</strong>')).to.eql('**<>!@#$%^&*()_+{}|[]**');
});
it('should convert <a href="x">y</a> to [y](x)', () => {
expect(textFromHtml('<a href="http://luketurner.org">link</a>')).to.eql('[link](http://luketurner.org)');
expect(textFromHtml('this is a <a href="http://luketurner.org">link</a>.')).to.eql('this is a [link](http://luketurner.org).');
expect(textFromHtml('<a href="http://luketurner.org"><>!@#$%^&*()_+{}|[]</a>')).to.eql('[<>!@#$%^&*()_+{}|[]](http://luketurner.org)');
});
it('should convert <a href="#tag"> to #tag', () => {
expect(textFromHtml('<a href="#tag">#tag</a>')).to.eql('#tag');
expect(textFromHtml('this is a <a href="#tag">#tag</a>...')).to.eql('this is a #tag...');
});
});
开发者ID:luketurner,项目名称:scripsi,代码行数:28,代码来源:text.spec.ts
示例16: describe
describe(Target.name, () => {
it('should get properties', () => {
const obj = {foo: 'bar'};
const target = new Target(obj, 'foo');
assert.strictEqual(target.key, 'foo');
assert.strictEqual(target.presetKey, 'foo');
});
it('should specify preset key', () => {
const obj = {foo: 'bar'};
const target = new Target(obj, 'foo', 'baz');
assert.strictEqual(target.presetKey, 'baz');
});
it('should read value', () => {
const obj = {foo: 'bar'};
const target = new Target(obj, 'foo');
assert.strictEqual(target.read(), 'bar');
});
it('should write value', () => {
const obj = {foo: 'bar'};
const target = new Target(obj, 'foo');
target.write('wrote');
assert.strictEqual(obj.foo, 'wrote');
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:27,代码来源:target-test.ts
示例17: describe
describe('datapoint processing', () => {
let waterrower;
beforeEach(done => {
waterrower = new WaterRower();
waterrower.setupStreams();
done();
})
it('treats distance as a hexadecimal integer', done => {
waterrower.once('data', point => {
assert.equal(point.name, 'distance');
assert.equal(point.value, 7350);
done();
});
waterrower.reads$.next({ time: 1468559128188, type: 'datapoint', data: 'IDD0571CB6\r'});
});
it('treats display minutes as a decimal integer', done => {
waterrower.once('data', point => {
assert.equal(point.name, 'display_min');
assert.equal(point.value, 28);
done();
});
waterrower.reads$.next({ time: 1468559128188, type: 'datapoint', data: 'IDS1E228\r'});
});
});
开发者ID:codefoster,项目名称:waterrower,代码行数:27,代码来源:test.ts
示例18: describe
describe(RangeConstraint.name, () => {
it('should constrain value with minimum value', () => {
const c = new RangeConstraint({
min: -10,
});
assert.strictEqual(c.minValue, -10);
assert.strictEqual(c.constrain(-11), -10);
assert.strictEqual(c.constrain(-10), -10);
assert.strictEqual(c.constrain(-9), -9);
});
it('should constrain value with maximum value', () => {
const c = new RangeConstraint({
max: 123,
});
assert.strictEqual(c.maxValue, 123);
assert.strictEqual(c.constrain(122), 122);
assert.strictEqual(c.constrain(123), 123);
assert.strictEqual(c.constrain(123.5), 123);
});
it('should constrain value with minimun and maximum value', () => {
const c = new RangeConstraint({
max: 123,
min: -123,
});
assert.strictEqual(c.constrain(-124), -123);
assert.strictEqual(c.constrain(0), 0);
assert.strictEqual(c.constrain(124), 123);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:31,代码来源:range-test.ts
示例19: describe
describe(InputBindingApi.name, () => {
it('should listen change event', (done) => {
const PARAMS = {
foo: 0,
};
const api = createApi(new Target(PARAMS, 'foo'));
api.on('change', (value) => {
assert.strictEqual(value, 123);
done();
});
api.controller.controller.value.rawValue = 123;
});
it('should refresh bound value', () => {
const PARAMS = {
foo: 0,
};
const api = createApi(new Target(PARAMS, 'foo'));
PARAMS.foo = 123;
api.refresh();
assert.strictEqual(api.controller.binding.value.rawValue, 123);
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:25,代码来源:input-binding-test.ts
示例20: describe
describe(GraphCursor.name, () => {
it('should get index', () => {
const c = new GraphCursor();
c.index = 123;
assert.strictEqual(c.index, 123);
});
it('should emit change event', (done) => {
const c = new GraphCursor();
c.emitter.on('change', (index) => {
assert.strictEqual(index, 123);
done();
});
c.index = 123;
});
it('should not emit change event for setting same index', () => {
const c = new GraphCursor();
c.index = 123;
c.emitter.on('change', () => {
throw new Error();
});
c.index = 123;
});
});
开发者ID:cocopon,项目名称:tweakpane,代码行数:25,代码来源:graph-cursor-test.ts
注:本文中的mocha.it函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论