本文整理汇总了TypeScript中Immutable.is函数的典型用法代码示例。如果您正苦于以下问题:TypeScript is函数的具体用法?TypeScript is怎么用?TypeScript is使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("merges streams of text", () => {
let outputs = Immutable.List();
outputs = reduceOutputs(outputs, {
name: "stdout",
text: "hello",
output_type: "stream"
});
expect(
Immutable.is(
outputs,
Immutable.fromJS([makeStreamOutput({ name: "stdout", text: "hello" })])
)
).toBe(true);
outputs = reduceOutputs(outputs, {
name: "stdout",
text: " world",
output_type: "stream"
});
expect(
Immutable.is(
outputs,
Immutable.fromJS([
makeStreamOutput({ name: "stdout", text: "hello world" })
])
)
).toBe(true);
});
示例2: it
it('expresses value equality with set sequences', () => {
var s1 = Set.of('A', 'B', 'C');
expect(s1.equals(null)).toBe(false);
var s2 = Set.of('C', 'B', 'A');
expect(s1 === s2).toBe(false);
expect(is(s1, s2)).toBe(true);
expect(s1.equals(s2)).toBe(true);
// Map and Set are not the same (keyed vs unkeyed)
var v1 = Map({ A: 'A', C: 'C', B: 'B' });
expect(is(s1, v1)).toBe(false);
});
示例3: it
it('surfaces NaN, null, and undefined', () => {
expect(
is(NaN, Seq.of(1, 2, 3, 4, 5, NaN).max())
).toBe(true);
expect(
is(NaN, Seq.of(NaN, 1, 2, 3, 4, 5).max())
).toBe(true);
expect(
is(null, Seq.of('A', 'B', 'C', 'D', null).max())
).toBe(true);
expect(
is(null, Seq.of(null, 'A', 'B', 'C', 'D').max())
).toBe(true);
});
示例4: function
compare: function(actual, expected) {
var passed = is(actual, expected);
return {
pass: passed,
message: 'Expected ' + actual + (passed ? '' : ' not') + ' to equal ' + expected
};
}
示例5: it
it('should initialize a game state record with default values', () => {
const choices = I.List([3, 4, 5]);
const correctChoice = 4;
const refreshChoices = spy(
(game: TestState) => game.set('choices', choices)
);
const refreshCorrectChoice = spy(
(game: TestState) => game.set('correctChoice', correctChoice)
);
const game = init(new TestStateRecord(), refreshChoices, refreshCorrectChoice);
assert.strictEqual(refreshChoices.callCount, 1);
assert.strictEqual(refreshCorrectChoice.callCount, 1);
assert.strictEqual(game.level, 1);
assert.strictEqual(game.step, 0);
assert(I.is(game.choices, choices));
assert.strictEqual(game.correctChoice, correctChoice);
assert.strictEqual(game.lastGuess, null);
assert.strictEqual(game.wasLastGuessCorrect, null);
assert.strictEqual(game.presentCount, 0);
assert.strictEqual(game.guessCount, 0);
assert.strictEqual(game.guessCountForCurrentCorrectChoice, 0);
assert.strictEqual(game.shouldRefreshChoices, false);
assert.strictEqual(game.shouldRefreshCorrectChoice, false);
assert.strictEqual(game.refreshChoicesCount, 1);
assert.strictEqual(game.refreshCorrectChoiceCount, 1);
});
示例6: expect
check.it('is not dependent on order', [genHeterogeneousishArray], vals => {
expect(
is(
Seq(shuffle(vals.slice())).max(),
Seq(vals).max()
)
).toEqual(true);
});
示例7: emit
emit(value:any) {
if (!refValues.has(this.key()) || !Immutable.is(refValues.get(this.key()), value)) {
const listeners = refListeners.get(this.key());
if (listeners) {
refValues.set(this.key(), value);
listeners.forEach(listener => listener(value));
}
}
}
示例8: Map
check.it('sets', {maxSize: 5000}, [gen.posInt], len => {
var map = Map();
for (var ii = 0; ii < len; ii++) {
expect(map.size).toBe(ii);
map = map.set(''+ii, ii);
}
expect(map.size).toBe(len);
expect(is(map.toSet(), Range(0, len).toSet())).toBe(true);
});