本文整理汇总了TypeScript中expect类的典型用法代码示例。如果您正苦于以下问题:TypeScript expect类的具体用法?TypeScript expect怎么用?TypeScript expect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了expect类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should throw if passed invalid store shape', () => {
let result = false;
Reflect.deleteProperty(store, 'dispatch');
try {
getAsyncInjectors(store);
} catch (err) {
result = err.name === 'Invariant Violation';
}
expect(result).toEqual(true);
});
示例2: it
it('does not append trailing separator when directory', function (done) {
var file = new File({
path: '/test/foo',
stat: {
isDirectory: function () {
return true;
},
} as any as fs.Stats,
});
expect(file.basename).toEqual('foo');
done();
});
示例3: it
it('resets the points of players', () => {
const initialState = new State()
.setIn(['players', 1], new Player({
points: 10,
}));
const state = reducer(initialState, {
type: 'startMatch',
endTime: 123,
});
expect(state.players.get(1).points).toEqual(0);
});
示例4: it
it('should override old image when ATTACH_IMAGE', () => {
const imageLink = 'http://whatever';
const newerImageLink = 'http://igiveashit';
const nodeId = this.leaf.data.id;
const action = graphManipulationActions.attachImageToNode(imageLink, this.leaf);
const newState = graphReducer(this.mockState, action);
const nextAction = graphManipulationActions.attachImageToNode(newerImageLink, this.leaf);
const newerState = graphReducer(newState, nextAction);
const nodeWithImage = findNode(newerState.raw, nodeId).node;
expect(nodeWithImage.image).toEqual(newerImageLink);
});
示例5: expect
Render.into(document.body, init, () => {
const [span, div, text] = Array.from(document.body.childNodes)
expect((span as HTMLElement).tagName).toBe('SPAN')
expect((div as HTMLElement).tagName).toBe('DIV')
expect(text).toExist()
expect(text.textContent).toBe('some text')
const updated = [
h('span'),
h('input'),
'some text (2)'
]
// Update 1: Swap the middle element
Render.into(init, updated, () => {
const [updatedSpan, input, updatedText] = Array.from(document.body.childNodes)
expect(updatedSpan).toBe(span)
expect((input as HTMLElement).tagName).toBe('INPUT')
expect(updatedText).toBe(text)
expect(updatedText.textContent).toBe('some text (2)')
const emptyNodes: VNode[] = []
// Update 2: Empty array
Render.into(updated, emptyNodes, () => {
expect(document.body.children.length).toBe(0)
// Update 3: Go back to the second VNode structure
Render.into(emptyNodes, updated, () => {
expect(document.body.childNodes.length).toBe(3)
done()
})
})
})
})
示例6: it
it('should render 2-level template with children and props', () => {
expect(render({
tagName: 'div',
children: {
tagName: 'div',
children: 'Hello',
props: {
'data-title': 'Greeting',
},
},
})).toBe(
'<div><div data-title="Greeting">Hello</div></div>'
);
});
示例7: it
it('copies history', function (done) {
var options = {
cwd: '/',
base: '/test/',
path: '/test/test.coffee',
contents: null,
};
var history = [
path.normalize('/test/test.coffee'),
path.normalize('/test/test.js'),
path.normalize('/test/test-938di2s.js'),
];
var file = new File(options);
file.path = history[1];
file.path = history[2];
var file2 = file.clone();
expect(file2.history).toEqual(history);
expect(file2.history).toNotBe(file.history);
expect(file2.path).toEqual(history[2]);
done();
});