本文整理匯總了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();
});