Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests #54

Merged
merged 2 commits into from
Dec 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions test-app/tests/unit/ember-metrics-simple-analytics-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,22 @@ module('Unit | Adapter | simple-analytics', function (hooks) {
test('#trackEvent calls simpleanalytics with the correct arguments', async function (assert) {
this.adapter.install();
await waitUntil(() => this.adapter.loaded);
assert.expect(1);
window.sa_event = (...args) =>
let done = assert.async();
window.sa_event = (...args) => {
assert.deepEqual(args, ['test', { plan: 'starter' }]);
done();
};
this.adapter.trackEvent({ name: 'test', plan: 'starter' });
});

test('#trackPage calls simpleanalytics with the correct arguments', async function (assert) {
this.adapter.install();
await waitUntil(() => this.adapter.loaded);
assert.expect(1);
window.sa_pageview = (...args) =>
let done = assert.async();
window.sa_pageview = (...args) => {
assert.deepEqual(args, ['/test', { plan: 'starter' }]);
done();
};
this.adapter.trackPage({ path: '/test', plan: 'starter' });
});

Expand All @@ -94,18 +98,22 @@ module('Unit | Adapter | simple-analytics', function (hooks) {
test('#trackEvent calls simpleanalytics with the correct arguments', async function (assert) {
this.adapter.install();
await waitUntil(() => this.adapter.loaded);
assert.expect(1);
window.mrloop_event = (...args) =>
let done = assert.async();
window.mrloop_event = (...args) => {
assert.deepEqual(args, ['test', { plan: 'starter' }]);
done();
};
this.adapter.trackEvent({ name: 'test', plan: 'starter' });
});

test('#trackPage calls simpleanalytics with the correct arguments', async function (assert) {
this.adapter.install();
await waitUntil(() => this.adapter.loaded);
assert.expect(1);
window.mrloop_pageview = (...args) =>
let done = assert.async();
window.mrloop_pageview = (...args) => {
assert.deepEqual(args, ['/test', { plan: 'starter' }]);
done();
};
this.adapter.trackPage({ path: '/test', plan: 'starter' });
});
});
Expand All @@ -114,8 +122,6 @@ module('Unit | Adapter | simple-analytics', function (hooks) {
module('queue', function () {
test('it queues events until the script is loaded', async function (assert) {
this.adapter.install();
assert.expect(3);
window.sa_event = (...args) => assert.deepEqual(args, ['turnip', {}]);
assert.false(this.adapter.loaded, 'adapter is not loaded');
this.adapter.trackEvent({ name: 'turnip' });
assert.deepEqual(
Expand All @@ -129,8 +135,6 @@ module('Unit | Adapter | simple-analytics', function (hooks) {

test('it queues page views until the script is loaded', async function (assert) {
this.adapter.install();
assert.expect(3);
window.sa_event = (...args) => assert.deepEqual(args, ['/veg', {}]);
assert.false(this.adapter.loaded, 'adapter is not loaded');
this.adapter.trackPage({ path: '/veg' });
assert.deepEqual(
Expand Down
Loading