Skip to content

Commit 9d53f56

Browse files
committed
fix tests
1 parent a5fe09c commit 9d53f56

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/internal/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ export let now = is_client
8686
? () => window.performance.now()
8787
: () => Date.now();
8888

89+
export let raf = is_client ? requestAnimationFrame : noop;
90+
8991
// used internally for testing
9092
export function set_now(fn) {
9193
now = fn;
9294
}
9395

94-
export const raf = is_client ? requestAnimationFrame : noop;
96+
export function set_raf(fn) {
97+
raf = fn;
98+
}

test/js/samples/debug-hoisted/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ class Component extends SvelteComponentDev {
5353
}
5454
}
5555

56-
export default Component;
56+
export default Component;

test/js/samples/media-bindings/expected.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
insert,
99
listen,
1010
noop,
11+
raf,
1112
run_all,
1213
safe_not_equal,
1314
time_ranges_to_array
@@ -18,7 +19,7 @@ function create_fragment(ctx) {
1819

1920
function audio_timeupdate_handler() {
2021
cancelAnimationFrame(audio_animationframe);
21-
if (!audio.paused) audio_animationframe = requestAnimationFrame(audio_timeupdate_handler);
22+
if (!audio.paused) audio_animationframe = raf(audio_timeupdate_handler);
2223
audio_updating = true;
2324
ctx.audio_timeupdate_handler.call(audio);
2425
}

test/runtime/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from "path";
33
import * as fs from "fs";
44
import { rollup } from 'rollup';
55
import * as virtual from 'rollup-plugin-virtual';
6-
import { clear_loops, set_now } from "../../internal.js";
6+
import { clear_loops, set_now, set_raf } from "../../internal.js";
77

88
import {
99
showOutput,
@@ -101,15 +101,15 @@ describe("runtime", () => {
101101
}
102102
};
103103
set_now(() => raf.time);
104-
global.requestAnimationFrame = cb => {
104+
set_raf(cb => {
105105
let called = false;
106106
raf.callback = () => {
107107
if (!called) {
108108
called = true;
109109
cb();
110110
}
111111
};
112-
};
112+
});
113113

114114
try {
115115
mod = require(`./samples/${dir}/main.svelte`);

0 commit comments

Comments
 (0)