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