Skip to content

Commit 964c93c

Browse files
committed
Refactor test structure in amp-slikeplayer tests for clarity and consistency
1 parent ecb2643 commit 964c93c

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

extensions/amp-slikeplayer/0.1/test/test-amp-slikeplayer.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import '../amp-slikeplayer';
2-
import {Services} from '#service';
32

43
import {listenOncePromise} from '#utils/event-helper';
54

@@ -90,7 +89,7 @@ describes.realWin(
9089
});
9190

9291
it('creates a placeholder when poster is provided', async () => {
93-
const {el, impl} = await buildPlayer({
92+
const {impl} = await buildPlayer({
9493
poster: 'https://example.com/poster.png',
9594
});
9695
const placeholder = impl.createPlaceholderCallback();
@@ -105,9 +104,9 @@ describes.realWin(
105104
const postSpy = env.sandbox.spy(impl, 'postMessage_');
106105
impl.seekTo(42);
107106
await Promise.resolve();
108-
const args = postSpy.getCalls().pop().args;
109-
expect(args[0]).to.equal('seekTo');
110-
expect(args[1]).to.equal(42);
107+
const [method, param] = postSpy.getCalls().pop().args;
108+
expect(method).to.equal('seekTo');
109+
expect(param).to.equal(42);
111110
});
112111

113112
it('supportsPlatform and isInteractive are true', async () => {
@@ -133,7 +132,7 @@ describes.realWin(
133132
});
134133

135134
it('updates currentTime on time/adTime events', async () => {
136-
const {impl, iframe} = await buildPlayer();
135+
const {iframe, impl} = await buildPlayer();
137136
impl.onMessage_({
138137
source: iframe.contentWindow,
139138
data: JSON.stringify({event: 'time', detail: {currentTime: 12}}),
@@ -147,7 +146,7 @@ describes.realWin(
147146
});
148147

149148
it('redispatches mapped events', async () => {
150-
const {el, impl, iframe} = await buildPlayer();
149+
const {el, iframe, impl} = await buildPlayer();
151150
const p = listenOncePromise(el, VideoEvents_Enum.PLAYING);
152151
impl.onMessage_({
153152
source: iframe.contentWindow,
@@ -157,7 +156,7 @@ describes.realWin(
157156
});
158157

159158
it('redispatches pause and complete, and visible', async () => {
160-
const {el, impl, iframe} = await buildPlayer();
159+
const {el, iframe, impl} = await buildPlayer();
161160
const p1 = listenOncePromise(el, VideoEvents_Enum.PAUSE);
162161
impl.onMessage_({
163162
source: iframe.contentWindow,
@@ -184,7 +183,10 @@ describes.realWin(
184183
const {impl} = await buildPlayer();
185184
const initial = impl.getCurrentTime();
186185
// Wrong source
187-
impl.onMessage_({source: {}, data: JSON.stringify({event: 'time', detail: {currentTime: 99}})});
186+
impl.onMessage_({
187+
source: {},
188+
data: JSON.stringify({event: 'time', detail: {currentTime: 99}}),
189+
});
188190
expect(impl.getCurrentTime()).to.equal(initial);
189191
// Non-JSON
190192
impl.onMessage_({source: null, data: 'not-json'});
@@ -198,9 +200,9 @@ describes.realWin(
198200
const postSpy = env.sandbox.spy(impl, 'postMessage_');
199201
impl.viewportCallback(true);
200202
await Promise.resolve();
201-
const lastArgs = postSpy.getCalls().pop().args;
202-
expect(lastArgs[0]).to.equal('handleViewport');
203-
expect(lastArgs[1]).to.equal(true);
203+
const [m, p] = postSpy.getCalls().pop().args;
204+
expect(m).to.equal('handleViewport');
205+
expect(p).to.equal(true);
204206
});
205207

206208
it('cleans up on unlayoutCallback', async () => {

0 commit comments

Comments
 (0)