Skip to content

Commit

Permalink
Merge pull request #54 from mrloop/em-remove-used-assertions
Browse files Browse the repository at this point in the history
Update tests
  • Loading branch information
mrloop authored Dec 17, 2023
2 parents 3a600a7 + 23f1421 commit 17cc4d9
Showing 1 changed file with 16 additions and 12 deletions.
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

0 comments on commit 17cc4d9

Please sign in to comment.